问题原因:
ringwater@ubuntu:~$ docker-machine create --driver generic --generic-ip-address=10.0.8.11 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...
管理的主机没有启用root,并且要开启ssh的root登录。
解决方法:
一、在安装docker machine的主机使用root登录并生成ssh-genkey
,并使用 ssh-copy-id考虑公钥到需要管理的主机
二、需要的管理主机上进行以下配置:
1 )允许root用户登录;编辑配置文件:
sudo vim /etc/ssh/sshd_config
PermitRootLogin prohibit-password
更改为:
PermitRootLogin yes
重启ssh服务:
sudo systemctl restart sshd
2) 创建密钥对(machine主机操作)
# ssh-keygen #一直回车
三、在安装docker machine的主机上使用命令进行管理
root@ubuntu:~# docker-machine create --driver generic --generic-ip-address=10.0.8.11 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)...
。。。。。。
四、ssh已经没有问题,继续对报错进行处理:
root@ubuntu:~# docker-machine create --driver generic --generic-ip-address=10.0.8.11 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: Error running apt-get update: ssh command error:
command : sudo apt-get update
err : exit status 100
output : Ign:1 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial InRelease
Ign:2 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial Release
Ign:3 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main amd64 Packages
Ign:4 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main i386 Packages
Ign:5 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main all Packages
Ign:6 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en_US
Ign:7 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en
Ign:8 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted amd64 Packages
Ign:9 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted i386 Packages
Ign:10 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted all Packages
Ign:11 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en_US
Ign:12 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en
Ign:3 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main amd64 Packages
Ign:4 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main i386 Packages
Ign:5 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main all Packages
Ign:6 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en_US
Ign:7 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en
Ign:8 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted amd64 Packages
Ign:9 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted i386 Packages
Ign:10 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted all Packages
Ign:11 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en_US
Ign:12 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en
Ign:3 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main amd64 Packages
Ign:4 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main i386 Packages
Ign:5 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main all Packages
Ign:6 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en_US
Ign:7 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en
Ign:8 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted amd64 Packages
Ign:9 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted i386 Packages
Ign:10 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted all Packages
Ign:11 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en_US
Ign:12 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en
Ign:3 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main amd64 Packages
Ign:4 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main i386 Packages
Ign:5 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main all Packages
Ign:6 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en_US
Ign:7 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en
Ign:8 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted amd64 Packages
Ign:9 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted i386 Packages
Ign:10 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted all Packages
Ign:11 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en_US
Ign:12 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en
Ign:3 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main amd64 Packages
Ign:4 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main i386 Packages
Ign:5 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main all Packages
Ign:6 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en_US
Ign:7 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main Translation-en
Ign:8 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted amd64 Packages
Ign:9 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted i386 Packages
Ign:10 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted all Packages
Ign:11 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en_US
Ign:12 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/restricted Translation-en
Err:3 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main amd64 Packages
Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs
Ign:4 cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial/main i386 Packages
Hit:13 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:14 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Hit:15 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:16 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
Reading package lists...
W: The repository 'cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8) xenial Release' does not have a Release file.
E: Failed to fetch cdrom://Ubuntu-Server 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.8)/dists/xenial/main/binary-amd64/Packages Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs
E: Some index files failed to download. They have been ignored, or old ones used instead.
更新源为阿里云的源:
$
sudo
su
-
# 切换到 root 目录
# cd /etc/apt/
# cp sources.list sources.list.bak
# true> sources.list
# vi /etc/apt/sources.list # 将上面的源复制到文件中, 保存退出
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
# apt update # 更新本地 apt 源
五、重新执行docker-machine create --driver generic --generic-ip-address=10.0.8.11 host1完成对host1的管理:
root@ubuntu:~# docker-machine create --driver generic --generic-ip-address=10.0.8.11 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