docker-machine: Error creating machine: Error running provisioning: ssh command error

问题描述:

当我使用docker-machine安装docker到另一台电脑的时候,遇到这个问题:

[felix@felix ~]$ docker-machine create --driver generic --generic-ssh-user felix  --generic-ip-address=172.125.1.71 host1
Running pre-create checks...
Creating machine...
(host1) No SSH key specified. Assuming an existing key at the default location.
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)...
Error creating machine: Error running provisioning: ssh command error:
command : sudo hostname host1 && echo "host1" | sudo tee /etc/hostname
err     : exit status 1
output  : sudo: no tty present and no askpass program specified

解决:

根据问题描述可以知道docker-machine登陆到host1,并且在host1上进行操作:sudo hostname host1 && echo "host1" | sudo tee /etc/hostname。于是我手动登陆到host1上进行操作,发现提示sudo的密码。

问题出现在从docker-machine登陆到host1上进行sudo操作却无法知道sudo密码。

解决办法是设置host1上登陆用户使用sudo时候不需要密码

设置方面如下:

1) 在host1运行 sudo visudo

2)在打开文件最后添加  username(felix) ALL=(ALL) NOPASSWD: ALL

3) 退出

 

再次运行docker-machine:

[felix@felix ~]$ docker-machine create --driver generic --generic-ssh-user felix  --generic-ip-address=172.125.1.71 host1
Running pre-create checks...
Creating machine...
(host1) No SSH key specified. Assuming an existing key at the default location.
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...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env host1

posted @ 2017-12-21 16:23  奔跑吧大龙  阅读(1175)  评论(0编辑  收藏  举报