Use official docker install script
add docker compose
This commit is contained in:
parent
372e11f0c2
commit
b55318da26
@ -1,4 +1,3 @@
|
|||||||
import platform
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
@ -16,38 +15,7 @@ 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")
|
subprocess.run("curl -fsSL https://get.docker.com | bash", shell=True)
|
||||||
subprocess.run("apt-get remove docker docker-engine docker.io containerd runc", shell=True)
|
subprocess.run("curl -L \"https://github.com/docker/compose/releases/download/"
|
||||||
subprocess.run("apt-get update", shell=True)
|
"1.25.4/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose"
|
||||||
subprocess.run(
|
"&& chmod +x /usr/local/bin/docker-compose", shell=True)
|
||||||
"apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common",
|
|
||||||
shell=True)
|
|
||||||
|
|
||||||
print("Checking for entry in /etc/apt/sources.list")
|
|
||||||
with open("/etc/apt/sources.list") as apt_list:
|
|
||||||
line = apt_list.read()
|
|
||||||
if "download.docker.com/linux/" not in line.lower():
|
|
||||||
print("apt-repo is not installed, setting up docker apt-key")
|
|
||||||
if "ubuntu" in platform.version().lower():
|
|
||||||
linux_distro = "ubuntu"
|
|
||||||
elif "debian" in platform.version().lower():
|
|
||||||
linux_distro = "debian"
|
|
||||||
else:
|
|
||||||
print("Version not supported by this installer")
|
|
||||||
return
|
|
||||||
|
|
||||||
base_url = f"https://download.docker.com/linux/{linux_distro}"
|
|
||||||
|
|
||||||
subprocess.run("curl -fsSL " + base_url + "/gpg | sudo apt-key add -", shell=True)
|
|
||||||
subprocess.run("apt-key fingerprint 0EBFCD88", shell=True)
|
|
||||||
subprocess.run("add-apt-repository \"deb [arch=amd64] " + base_url + " $(lsb_release -cs) stable\"",
|
|
||||||
shell=True)
|
|
||||||
else:
|
|
||||||
print("skip adding of the key")
|
|
||||||
|
|
||||||
print("Installing the Service")
|
|
||||||
subprocess.run("apt-get update", shell=True)
|
|
||||||
subprocess.run("apt-get install -y docker-ce docker-ce-cli containerd.io", shell=True)
|
|
||||||
|
|
||||||
print("Checking the installation")
|
|
||||||
subprocess.run("docker run --rm hello-world", shell=True)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user