machine icon indicating copy to clipboard operation
machine copied to clipboard

docker-machine create fail: sudo systemctl -f start docker exit status 1

Open mberaha opened this issue 9 years ago • 20 comments

Hello,

with the newest docker-machine 0.12.1, build c8b17e8 and docker 17.06.0-ce, build 02c1d87 when running:

docker-machine create \
  --driver amazonec2 \
  --amazonec2-access-key ${AWS_ACCESS_KEY_ID} \
  --amazonec2-secret-key ${AWS_SECRET_ACCESS_KEY} \
  --amazonec2-region eu-west-1 \
  --amazonec2-security-group bt-security-group \
  --amazonec2-instance-type ${INSTANCE_TYPE}  \
 ${NAME}

I get the following log and error:

Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Error creating machine: Error running provisioning: ssh command error:
command : sudo systemctl -f start docker
err     : exit status 1
output  : Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

mberaha avatar Jul 03 '17 09:07 mberaha

Same for me, with older versions:

(services)  synon (master) ✗ docker --version
Docker version 17.05.0-ce, build 89658be
(services)  synon (master) ✗ dm --version    
docker-machine version 0.11.0, build 5b27455

I am using docker-machine to setup docker on my remote instance. The daemon refuses to start

(services)  synon (master) ✗ docker-machine create --driver amazonec2 --amazonec2-region=us-west-2 --amazonec2-zone=a --amazonec2-instance-type=c4.xlarge --amazonec2-ami=ami-efd0428f synon
Running pre-create checks...
Creating machine...
(synon) Launching instance...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Error creating machine: Error running provisioning: ssh command error:
command : sudo systemctl -f start docker
err     : exit status 1
output  : Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

My sytemctl status docker.service

ubuntu@synon:~$ systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/docker.service.d
           └─10-machine.conf
   Active: inactive (dead) (Result: exit-code) since Mon 2017-07-03 09:07:57 UTC; 2min 37s ago
     Docs: https://docs.docker.com
  Process: 5352 ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tls
 Main PID: 5352 (code=exited, status=1/FAILURE)

Jul 03 09:07:57 synon systemd[1]: Failed to start Docker Application Container Engine.
Jul 03 09:07:57 synon systemd[1]: docker.service: Unit entered failed state.
Jul 03 09:07:57 synon systemd[1]: docker.service: Failed with result 'exit-code'.
Jul 03 09:07:57 synon systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Jul 03 09:07:57 synon systemd[1]: Stopped Docker Application Container Engine.
Jul 03 09:07:57 synon systemd[1]: docker.service: Start request repeated too quickly.
Jul 03 09:07:57 synon systemd[1]: Failed to start Docker Application Container Engine.
lines 1-16/16 (END)Wrapper Docker Machine process exiting due to closed plugin server (unexpected EOF)

This is my journalctl -xe:

ubuntu@synon:~$ journalctl -xe
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Jul 03 09:10:24 synon systemd[5362]: Reached target Default.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit UNIT has finished starting up.
-- 
-- The start-up result is done.
Jul 03 09:10:24 synon systemd[5362]: Startup finished in 7ms.
-- Subject: System start-up is now complete
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- All system services necessary queued for starting at boot have been
-- successfully started. Note that this does not mean that the machine is
-- now idle as services might still be busy with completing start-up.
-- 
-- Kernel start-up required KERNEL_USEC microseconds.
-- 
-- Initial RAM disk start-up required INITRD_USEC microseconds.
-- 
-- Userspace start-up required 7322 microseconds.
Jul 03 09:10:24 synon systemd[1]: Started User Manager for UID 1000.
-- Subject: Unit [email protected] has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit [email protected] has finished starting up.
-- 
-- The start-up result is done.
Jul 03 09:16:25 synon sudo[5414]:   ubuntu : TTY=pts/0 ; PWD=/home/ubuntu ; USER=root ; COMMAND=/bin/ls /var/lib/docker
Jul 03 09:16:25 synon sudo[5414]: pam_unix(sudo:session): session opened for user root by ubuntu(uid=0)
Jul 03 09:16:25 synon sudo[5414]: pam_unix(sudo:session): session closed for user root
Jul 03 09:17:01 synon CRON[5418]: pam_unix(cron:session): session opened for user root by (uid=0)
Jul 03 09:17:01 synon CRON[5419]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jul 03 09:17:01 synon CRON[5418]: pam_unix(cron:session): session closed for user root

I don't see anything wrong anywhere, why is my docker engine refusing to start?

darshanchaudhary avatar Jul 03 '17 09:07 darshanchaudhary

Same with Digital Ocean and, I am pretty sure, with other drivers.

As mentioned in https://forums.docker.com/t/docker-machine-provisioned-aws-instance-can-not-start-docker-engine/34200/4?u=ramoiseev there is workaround

--engine-install-url=https://web.archive.org/web/20170623081500/https://get.docker.com

I can confirm it works for DO and EC2

r-moiseev avatar Jul 03 '17 13:07 r-moiseev

I hit same problem, the line in the log got me attention:

  Process: 5352 ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tls

docker daemon should be dockerd, as docker daemon is deprecated and removed long time ago.

twang2218 avatar Jul 04 '17 06:07 twang2218

I've got the same problem with 0.12.0, the generic driver and ubuntu target but 0.12.1 fixes my problem (cf. https://github.com/docker/machine/commit/efe0ca527346937badc39b649d032e8e4a33fcd7)

aolwas avatar Jul 05 '17 10:07 aolwas

I have ran into the same issue but have managed to possibly find a solution with the same idea that @twang2218 mentioned:

Trying to create a docker-machine with the -d amazonec2 driver on the latest ubuntu linux ami-d15a75c7.

docker-machine create -d amazonec2 --amazonec2-ami ami-d15a75c7 ...

Which we know produces this error:

Error creating machine: Error running provisioning: ssh command error:
command : sudo systemctl -f start docker
err     : exit status 1
output  : Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

After investigating the logs the process being executed is:

ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=amazonec2

from the file at /etc/systemd/system/docker.service.d/10-machine.conf

But the docker daemon command is not supported on Linux and should it not be changed to this?

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=amazonec2

Further investigation, and after editing the /etc/systemd/system/docker.service.d/10-machine.conf file, I changed the ExecStart to be /usr/bin/dockerd instead of /user/bin/docker daemon, restarted the systemctl daemon systemctl daemon-reload, and ran sudo systemctl -f start docker again and everything runs fine.

edit: changed some wording

jeremills avatar Jul 05 '17 15:07 jeremills

This is a duplicate of #4156. An other solution is to use Racher's install script to install 17.05 CE.

leesei avatar Jul 05 '17 16:07 leesei

no idea if this is duplicated, i've got latest docker, and dockerd in that newly created config and it still crashing

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic --live-restore=true
Environment=
~                                                                                                                                                                                                                   
~                     

holms avatar Jul 13 '17 21:07 holms

@holms try -engine-storage-driver=overlayfs

r-moiseev avatar Jul 13 '17 22:07 r-moiseev

@r-moiseev Worked with -engine-storage-driver=overlay2

holms avatar Jul 13 '17 22:07 holms

Just leaving a note here in case anyone else wanders down this path of madness. If you're using Docker Machine with the AWS Engine, bear in mind that it has a preconfigured set of AMI IDs that it uses and they vary per region.

Apparently, Docker doesn't update it's AWS Engine AMI IDs very often. As such, when launching into say eu-west-1, the ubuntu AMI was dated 2015 and was a wily distribution. It seems like Docker no longer distributes a Docker build for Wily on get.docker.com and so the deployment of Docker would "silently" fail. The error messages provided aren't helpful and can be misconstrued for many other symptoms.

I'd suggest checking the AMI you're launching and make sure it's a recent distribution so as to keep up with Docker's distributed binaries.

uzquiano avatar Jul 17 '17 14:07 uzquiano

I believe this is related to docker-machine create issue that is being reported in multiple recent tickets:

  • https://github.com/docker/machine/issues/4156
  • https://github.com/docker/machine/issues/4166
  • https://github.com/docker/machine/issues/4189
  • https://github.com/docker/machine/issues/4197
  • https://github.com/docker/machine/issues/4198

brandontamm avatar Jul 17 '17 15:07 brandontamm

The issue is caused by the version schema changes, and has been fixed in 0.12.1, however, the version of docker-machine inside the Docker for Mac is still 0.12.0. That might be the reason, people keep complaining about the issue. I think Docker for Mac should update its docker-machine version.

twang2218 avatar Jul 17 '17 18:07 twang2218

I updated the list of AMIs in 0.12.2, which should resolve any remaining issues with EC2 provisioning.

shin- avatar Jul 17 '17 18:07 shin-

@shin- I can confirm that these issues still occur in v0.12.2

brandontamm avatar Jul 17 '17 18:07 brandontamm

Its because there is not only issue with systemd (wich was fixed in 0.12.1). Issue with storage-driver (wich is aufs somehow) is not fixed

r-moiseev avatar Jul 17 '17 19:07 r-moiseev

@r-moiseev Fixed in 0.12.2 for EC2.

shin- avatar Jul 17 '17 19:07 shin-

For the generic driver the --engine-storage-driver=overlay2 option solves similar issue for me.

petk avatar Jul 24 '17 13:07 petk

Hi @shin- the suggestion from @petk solved my issue #4190, do you think it should be fixed in a new release?

princemaple avatar Aug 07 '17 05:08 princemaple

upgrate to latest docker machine.... follow below instructions... https://docs.docker.com/machine/install-machine/#installing-machine-directly

prageethw avatar Aug 28 '17 00:08 prageethw

Anyone having this issue - use brew to override your docker-machine install temporarily:

brew install docker-machine && brew unlink docker-machine && brew link --overwrite docker-machine

brandontamm avatar Aug 28 '17 13:08 brandontamm