![Docker-machine 搞乱了主机上的 docker](https://linux22.com/image/710682/Docker-machine%20%E6%90%9E%E4%B9%B1%E4%BA%86%E4%B8%BB%E6%9C%BA%E4%B8%8A%E7%9A%84%20docker.png)
在 Digital Ocean 中创建 Ubuntu 16.04 Droplet 后,我尝试从本地计算机将其与 docker-machine 连接,但服务器的 docker 无法启动。我实际上尝试了两种方式:第一种是在服务器上安装 docker,第二种是不安装 docker,因为当您执行命令时,docker-machine create ...
它会安装并覆盖服务器上的任何 docker,最终导致在那里创建失败的 docker 实例。我在防火墙中启用了端口 22、80、443 和 2376。machine create 是否有不在主机中安装 docker 的选项?
$ docker-machine create --driver=generic \
--generic-ip-address=XXX.XXX.XXX.XXX \
--generic-ssh-user=rinaldi \
--generic-ssh-key=C:/Users/[...]/id_rsa \
--generic-ssh-port=22 \
DigitalOcean
Running pre-create checks...
Creating machine...
(DigitalOcean) Importing SSH key...
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.
这是服务器上的 systemctl -xe
-- Unit docker.service has finished shutting down.
Sep 19 02:11:24 DigitalOcean systemd[1]: Closed Docker Socket for the API.
-- Subject: Unit docker.socket has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has finished shutting down.
Sep 19 02:11:24 DigitalOcean systemd[1]: Stopping Docker Socket for the API.
-- Subject: Unit docker.socket has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has begun shutting down.
Sep 19 02:11:24 DigitalOcean systemd[1]: Starting Docker Socket for the API.
-- Subject: Unit docker.socket has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has begun starting up.
Sep 19 02:11:24 DigitalOcean systemd[1]: Listening on Docker Socket for the API.
-- Subject: Unit docker.socket has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has finished starting up.
--
-- The start-up result is done.
Sep 19 02:11:24 DigitalOcean systemd[1]: docker.service: Start request repeated too quickly.
Sep 19 02:11:24 DigitalOcean systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Sep 19 02:11:24 DigitalOcean systemd[1]: docker.socket: Unit entered failed state.
Sep 19 02:11:40 DigitalOcean sshd[3898]: Did not receive identification string from [...]
Sep 19 02:11:40 DigitalOcean sshd[6889]: Did not receive identification string from [...]
Sep 19 02:12:32 DigitalOcean kernel: [UFW BLOCK] IN=eth0 OUT= MAC=[...] SRC=[...] DST=[...] LEN=40 TOS=0x00 PREC=0x0
Sep 19 02:12:40 DigitalOcean sudo[7183]: rinaldi : TTY=pts/0 ; PWD=/home/rinaldi ; USER=root ; COMMAND=/bin/journalctl -xe
Sep 19 02:12:40 DigitalOcean sudo[7183]: pam_unix(sudo:session): session opened for user root by rinaldi(uid=0)
答案1
看来这是 docker-machine 0.11 上的一个错误,但它已在 0.12 上修复,如果您需要在 0.11 上工作,那么这里是解决方案。
替换此行/etc/systemd/system/docker.service.d/10-machine.conf
然后运行 systemctl daemon-reload 应该可以解决问题。
# ExecStart=/usr/bin/docker daemon -H ...
ExecStart=/usr/bin/dockerd -H ...
来源: https://github.com/docker/for-linux/issues/11#issuecomment-327441650