Add auto accept and platform distinction in docker

This commit is contained in:
Marcel Schwarz 2020-03-10 23:12:19 +01:00
parent dcb8374f70
commit 7705ba9cae

View File

@ -1,4 +1,5 @@
import json import json
import platform
import subprocess import subprocess
@ -24,17 +25,26 @@ class ToolsInstaller:
def docker(self): def docker(self):
"""Install the Docker service on the machine""" """Install the Docker service on the machine"""
print("Removing any old installations") print("Removing any old installations")
subprocess.run("apt-get remove docker docker-engine docker.io containerd runc", shell=True) subprocess.run("apt-get remove docker docker-engine docker.io containerd runc", shell=True)
print("Set up docker apt-key") print("Set up docker apt-key")
subprocess.run("apt-get update", shell=True) subprocess.run("apt-get update", shell=True)
subprocess.run("apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common", shell=True) subprocess.run(
"apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common",
shell=True)
subprocess.run("curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -", shell=True) subprocess.run("curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -", shell=True)
subprocess.run("apt-key fingerprint 0EBFCD88", shell=True) subprocess.run("apt-key fingerprint 0EBFCD88", shell=True)
if "ubuntu" in platform.version().lower():
subprocess.run("add-apt-repository " subprocess.run("add-apt-repository "
"\"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs)stable\"", shell=True) "\"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable\"",
shell=True)
elif "debian" in platform.version().lower():
subprocess.run("add-apt-repository "
"\"deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable\"",
shell=True)
print("Installing the Service") print("Installing the Service")
subprocess.run("apt-get update", shell=True) subprocess.run("apt-get update", shell=True)
subprocess.run("apt-get install docker-ce docker-ce-cli containerd.io", shell=True) subprocess.run("apt-get install -y docker-ce docker-ce-cli containerd.io", shell=True)
print("Checking the installation") print("Checking the installation")
subprocess.run("docker run hello-world", shell=True) subprocess.run("docker run hello-world", shell=True)