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

转载于:https://www.cnblogs.com/felixwa/p/8081187.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值