| |
@@ -86,13 +86,18 @@
|
| |
raise RuntimeError("Could not parse DOCKER_EXTRA_ARGS")
|
| |
logger.info("Launching Docker container for {0}".format(image))
|
| |
# Make sure the docker service is running
|
| |
- cmd = [
|
| |
- "/usr/bin/systemctl", "start", "docker"
|
| |
- ]
|
| |
try:
|
| |
- subprocess.check_call(cmd, stdout=sys.stderr.fileno())
|
| |
+ subprocess.check_call(["/usr/bin/systemctl", "is-active", "--quiet", "docker"],
|
| |
+ stdout=sys.stderr.fileno())
|
| |
except subprocess.CalledProcessError:
|
| |
- raise RuntimeError("Could not start docker service")
|
| |
+ try:
|
| |
+ cmd = [
|
| |
+ "/usr/bin/systemctl", "start", "docker"
|
| |
+ ]
|
| |
+ subprocess.check_call(cmd, stdout=sys.stderr.fileno())
|
| |
+ except subprocess.CalledProcessError:
|
| |
+ raise RuntimeError("Could not start docker service")
|
| |
+
|
| |
# And launch the actual container
|
| |
cmd = [
|
| |
"/usr/bin/docker", "run", "--detach", "--cidfile={0}".format(cidfile),
|
| |
Only run
systemctl start docker
whensystemctl is-active docker
fails. The start command is privileged and therefore requires manual
authentication if it is run by a non-root user even if the service is
already active. The check with is-active is possible without special
privileges. This allows to use the inventory file if the current user is
in the docker group.