当前位置:   article > 正文

Centos7 docker-machine 部署docker主机 docker服务启动失败_error creating machine: error running provisioning

error creating machine: error running provisioning: could not find matching

背景:

        计划使用Centos7 Core 作为 docker host,搭建测试平台,只有4台主机,就使用Swarm方案。

环境:

主机名称系统IP地址前置工作
docker-host1CentOS7 Corexxx.xxx.xxx.80

更新yum源,使用aliyun镜像,更新到最新状态

配置docker-machine 使用的用户,sudo免密码

docker-host2CentOS7 Corexxx.xxx.xxx.81

更新yum源,使用aliyun镜像,更新到最新状态

配置docker-machine 使用的用户,sudo免密码

docker-host3CentOS7 Corexxx.xxx.xxx.82

更新yum源,使用aliyun镜像,更新到最新状态

配置docker-machine 使用的用户,sudo免密码

docker-host4CentOS7 Corexxx.xxx.xxx.83

更新yum源,使用aliyun镜像,更新到最新状态

配置docker-machine 使用的用户,sudo免密码

desktopubuntu-18.04lts 配置免秘钥登录到docker-host

安装:

在工作desktop(Ubuntu)主机上安装 docker-machine,可以参考https://docs.docker.com/machine/install-machine/

首先安装 docker-host1:

docker-machine --debug create --driver generic --generic-ip-address=xxx.xxx.xxx.80   --generic-ssh-key=/home/sleeber/.ssh/id_rsa --generic-ssh-port=22 --generic-ssh-user=wntime docker-host1

安装最后输出,显示docker 服务无法启动:

  1. sudo systemctl -f start docker
  2. SSH cmd err, output: exit status 1: Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
  3. Error creating machine: Error running provisioning: something went wrong running an SSH command
  4. command : sudo systemctl -f start docker
  5. err : exit status 1
  6. output : Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
  7. notifying bugsnag: [Error creating machine: Error running provisioning: something went wrong running an SSH command
  8. command : sudo systemctl -f start docker
  9. err : exit status 1
  10. output : Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
  11. ]

使用docker-machine ls 查看主机状态:

  1. :~/docker-test-env$ docker-machine ls
  2. NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
  3. docker-host1 - generic Running tcp://xxx.xxx.xxx.80:2376 Unknown Unable to query docker version: Cannot connect to the docker engine endpoint

SSH到docker-host1 主机,手动启动docker服务

  1. sudo systemctl start docker
  2. Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

按照提示查看状态

  1. systemctl status docker.service
  2. ● docker.service - Docker Application Container Engine
  3. Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
  4. Drop-In: /etc/systemd/system/docker.service.d
  5. └─10-machine.conf
  6. Active: failed (Result: start-limit) since Thu 2020-05-28 20:41:39 EDT; 581ms ago
  7. Docs: https://docs.docker.com
  8. Process: 30463 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver overlay2 --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic (code=exited, status=1/FAILURE)
  9. Main PID: 30463 (code=exited, status=1/FAILURE)

谷歌一下:

https://github.com/moby/moby/issues/33931

https://www.jianshu.com/p/bd395fdf7611

https://www.jianshu.com/p/93518610eea1

按照搜索结果看,应该是10-machine.conf引起;但是删除了10-machine.conf文件,及文件夹还是无法启动

  1. $ sudo rm /etc/systemd/system/docker.service.d/10-machine.conf
  2. $ sudo systemctl start docker
  3. Failed to start docker.service: Unit is not loaded properly: Invalid argument.
  4. See system logs and 'systemctl status docker.service' for details.
  5. $ sudo rm -rf /etc/systemd/system/docker.service.d/
  6. $ sudo systemctl start docker
  7. Failed to start docker.service: Unit is not loaded properly: Invalid argument.
  8. See system logs and 'systemctl status docker.service' for details.

使用dockerd 直接能启动

  1. $ sudo nohup dockerd &
  2. [1] 31419
  3. $ nohup: ignoring input and appending output to ‘nohup.out’
  4. $ ll
  5. total 4
  6. -rw-------. 1 root root 2638 May 28 20:52 nohup.out
  7. $ tail -f nohup.out
  8. tail: cannot open ‘nohup.out’ for reading: Permission denied
  9. tail: no files remaining
  10. $ sudo tail -f nohup.out
  11. time="2020-05-28T20:52:56.409646032-04:00" level=warning msg="Base device already exists and has filesystem xfs on it. User specified filesystem will be ignored." storage-driver=devicemapper
  12. time="2020-05-28T20:52:56.430282474-04:00" level=info msg="[graphdriver] using prior storage driver: devicemapper"
  13. time="2020-05-28T20:52:56.430326847-04:00" level=warning msg="[graphdriver] WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release"
  14. time="2020-05-28T20:52:56.433336530-04:00" level=warning msg="mountpoint for pids not found"
  15. time="2020-05-28T20:52:56.433595847-04:00" level=info msg="Loading containers: start."
  16. time="2020-05-28T20:52:56.529329426-04:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
  17. time="2020-05-28T20:52:56.558933143-04:00" level=info msg="Loading containers: done."
  18. time="2020-05-28T20:52:56.570819898-04:00" level=info msg="Docker daemon" commit=9d988398e7 graphdriver(s)=devicemapper version=19.03.9
  19. time="2020-05-28T20:52:56.570873940-04:00" level=info msg="Daemon has completed initialization"
  20. time="2020-05-28T20:52:56.585131361-04:00" level=info msg="API listen on /var/run/docker.sock"
  21. ^C
  22. $ sudo docker version
  23. Client: Docker Engine - Community
  24. Version: 19.03.9
  25. API version: 1.40
  26. Go version: go1.13.10
  27. Git commit: 9d988398e7
  28. Built: Fri May 15 00:25:27 2020
  29. OS/Arch: linux/amd64
  30. Experimental: false
  31. Server: Docker Engine - Community
  32. Engine:
  33. Version: 19.03.9
  34. API version: 1.40 (minimum version 1.12)
  35. Go version: go1.13.10
  36. Git commit: 9d988398e7
  37. Built: Fri May 15 00:24:05 2020
  38. OS/Arch: linux/amd64
  39. Experimental: false
  40. containerd:
  41. Version: 1.2.13
  42. GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
  43. runc:
  44. Version: 1.0.0-rc10
  45. GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
  46. docker-init:
  47. Version: 0.18.0
  48. GitCommit: fec3683

使用systemctl 查看docker服务状态还是显示失败

  1. $ sudo systemctl status docker
  2. ● docker.service - Docker Application Container Engine
  3. Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
  4. Drop-In: /etc/systemd/system/docker.service.d
  5. └─10-machine.conf
  6. Active: failed (Result: start-limit) since Thu 2020-05-28 20:49:52 EDT; 4min 59s ago
  7. Docs: https://docs.docker.com
  8. Process: 31051 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver overlay2 --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic (code=exited, status=1/FAILURE)
  9. Main PID: 31051 (code=exited, status=1/FAILURE)
  10. May 28 20:49:50 test-java2 systemd[1]: docker.service failed.
  11. May 28 20:49:52 test-java2 systemd[1]: docker.service holdoff time over, scheduling restart.
  12. May 28 20:49:52 test-java2 systemd[1]: Stopped Docker Application Container Engine.
  13. May 28 20:49:52 test-java2 systemd[1]: start request repeated too quickly for docker.service
  14. May 28 20:49:52 test-java2 systemd[1]: Failed to start Docker Application Container Engine.
  15. May 28 20:49:52 test-java2 systemd[1]: Unit docker.service entered failed state.
  16. May 28 20:49:52 test-java2 systemd[1]: docker.service failed.
  17. May 28 20:50:45 test-java2 systemd[1]: start request repeated too quickly for docker.service
  18. May 28 20:50:45 test-java2 systemd[1]: Failed to start Docker Application Container Engine.
  19. May 28 20:50:45 test-java2 systemd[1]: docker.service failed.

推断 docker-machine 安装docker还是有些问题,只能手动安装

注意:卸载docker后,需要手动删除/etc/systemd/system/docker.service.d/ 文件夹,否则新安装的docker也是不能启动的。

卸载现有docker,并重新安装

  1. sudo yum remove docker* \
  2. docker-client \
  3. docker-client-latest \
  4. docker-common \
  5. docker-latest \
  6. docker-latest-logrotate \
  7. docker-logrotate \
  8. docker-engine
  9. sudo rm -rf /etc/systemd/system/docker.service.d/
  10. sudo yum install -y yum-utils device-mapper-persistent-data lvm2
  11. sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  12. sudo yum install -y docker-ce docker-ce-cli containerd.io

启动docker,并查看docker服务状态

  1. $ sudo docker version
  2. Client: Docker Engine - Community
  3. Version: 19.03.10
  4. API version: 1.40
  5. Go version: go1.13.10
  6. Git commit: 9424aeaee9
  7. Built: Thu May 28 22:18:06 2020
  8. OS/Arch: linux/amd64
  9. Experimental: false
  10. Server: Docker Engine - Community
  11. Engine:
  12. Version: 19.03.10
  13. API version: 1.40 (minimum version 1.12)
  14. Go version: go1.13.10
  15. Git commit: 9424aeaee9
  16. Built: Thu May 28 22:16:43 2020
  17. OS/Arch: linux/amd64
  18. Experimental: false
  19. containerd:
  20. Version: 1.2.13
  21. GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
  22. runc:
  23. Version: 1.0.0-rc10
  24. GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
  25. docker-init:
  26. Version: 0.18.0
  27. GitCommit: fec3683

可以正常启动了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/973761
推荐阅读
相关标签
  

闽ICP备14008679号