在docker的使用过程中,有可能你会遇到如题所示的错误。
该错误在我的环境里是发生在MS Windows上的“boot2docker up”的命令执行之后。
并且,在“boot2docker ssh”的时候,也会出现同样的错误。

即,无法通过boot2docker,从宿主机连入虚拟机。

对于该问题,它的一种解法如下所示:
(这里,我的终端模拟工具为:Git Bash)

logical_mind@LOGICAL_MIND-PC ~
$ boot2docker up -v
Boot2Docker-cli version: v1.3.2
Git commit: e41a9ae
2014/12/15 10:00:02 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 showvminfo boot2docker-vm --machinereadable
2014/12/15 10:00:04 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 guestproperty set boot2docker-vm /VirtualBox/GuestAdd/SharedFolders/MountPrefix
 /
2014/12/15 10:00:04 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 guestproperty set boot2docker-vm /VirtualBox/GuestAdd/SharedFolders/MountDir /
2014/12/15 10:00:04 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 sharedfolder add boot2docker-vm --name c/Users --hostpath C:\Users --automount
VBoxManage.exe: error: Shared folder named 'c/Users' already exists
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), componen
t SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "CreateSharedFolder(Bstr(name).raw(), Bstr(hostp
ath).raw(), fWritable, fAutoMount)" at line 1009 of file VBoxManageMisc.cpp
2014/12/15 10:00:04 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 setextradata boot2docker-vm VBoxInternal2/SharedFoldersEnableSymlinksCreate/c/U
sers 1
2014/12/15 10:00:04 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 startvm boot2docker-vm --type headless
Waiting for VM "boot2docker-vm" to power on...
VM "boot2docker-vm" has been successfully started.
2014/12/15 10:00:07 executing: C:\Program Files\Oracle\VirtualBox\VBoxManage.exe
 showvminfo boot2docker-vm --machinereadable
Waiting for VM and Docker daemon to start...
.Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2
022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to t
cp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0)
.Connecting to tcp://localhost:2022 (attempt #0).Connecting to tcp://localhost:2
022 (attempt #0).Connecting to tcp://localhost:2022 (attempt #0).Connecting to t
cp://localhost:2022 (attempt #0)2014/12/15 10:00:18 executing: C:\Program Files
(x86)\Git\bin\ssh.exe ssh -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o U
serKnownHostsFile=/dev/null -o LogLevel=quiet -p 2022 -i c:\Users\logical_mind\.
ssh\id_boot2docker docker@localhost ip addr show dev eth1
SSH returned: 4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fa
st state UP qlen 1000
    link/ether 08:00:27:b4:8a:a6 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a00:27ff:feb4:8aa6/64 scope link tentative
       valid_lft forever preferred_lft forever

END SSH
.Connecting to tcp://localhost:2022 (attempt #0)2014/12/15 10:00:18 executing: C
:\Program Files (x86)\Git\bin\ssh.exe ssh -o IdentitiesOnly=yes -o StrictHostKey
Checking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -p 2022 -i c:\User
s\logical_mind\.ssh\id_boot2docker docker@localhost ip addr show dev eth1
SSH returned: 4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fa
st state UP qlen 1000
    link/ether 08:00:27:b4:8a:a6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.59.103/24 brd 192.168.59.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:feb4:8aa6/64 scope link tentative
       valid_lft forever preferred_lft forever

END SSH
VM Host-only IP address: 192.168.59.103
Waiting for Docker daemon to start...
o2014/12/15 10:00:18 executing: C:\Program Files (x86)\Git\bin\ssh.exe ssh -o Id
entitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o
LogLevel=quiet -p 2022 -i c:\Users\logical_mind\.ssh\id_boot2docker docker@local
host grep tcp:// /proc/$(cat /var/run/docker.pid)/cmdline
cat: can't open '/var/run/docker.pid': No such file or directory
Error requesting socket: exit status 1
o2014/12/15 10:00:19 executing: C:\Program Files (x86)\Git\bin\ssh.exe ssh -o Id
entitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o
LogLevel=quiet -p 2022 -i c:\Users\logical_mind\.ssh\id_boot2docker docker@local
host grep tcp:// /proc/$(cat /var/run/docker.pid)/cmdline
cat: can't open '/var/run/docker.pid': No such file or directory
Error requesting socket: exit status 1
o2014/12/15 10:00:20 executing: C:\Program Files (x86)\Git\bin\ssh.exe ssh -o Id
entitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o
LogLevel=quiet -p 2022 -i c:\Users\logical_mind\.ssh\id_boot2docker docker@local
host grep tcp:// /proc/$(cat /var/run/docker.pid)/cmdline
SSH returned: tcp://0.0.0.0:2376

END SSH
2014/12/15 10:00:20 executing: C:\Program Files (x86)\Git\bin\ssh.exe ssh -o Ide
ntitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o L
ogLevel=quiet -p 2022 -i c:\Users\logical_mind\.ssh\id_boot2docker docker@localh
ost ip addr show dev eth1
SSH returned: 4: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fa
st state UP qlen 1000
    link/ether 08:00:27:b4:8a:a6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.59.103/24 brd 192.168.59.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:feb4:8aa6/64 scope link
       valid_lft forever preferred_lft forever

END SSH

Started.
2014/12/15 10:00:20 executing: C:\Program Files (x86)\Git\bin\ssh.exe ssh -o Ide
ntitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o L
ogLevel=quiet -p 2022 -i c:\Users\logical_mind\.ssh\id_boot2docker docker@localh
ost tar c /home/docker/.docker/*.pem
tar: Removing leading `/' from member names
Writing c:\Users\logical_mind\.boot2docker\certs\boot2docker-vm\ca.pem
Writing c:\Users\logical_mind\.boot2docker\certs\boot2docker-vm\cert.pem
Writing c:\Users\logical_mind\.boot2docker\certs\boot2docker-vm\key.pem
Docker client does not run on Windows for now. Please use
    "g:\Program Files\Boot2Docker for Windows\boot2docker.exe" ssh
to SSH into the VM instead.


logical_mind@LOGICAL_MIND-PC ~
$

首先,如上命令所示,在“boot2docker up”的时候,跟上参数“-v”,以便于查看详细的启动日志信息。
你可以在以上的日志中,找到Docker所在的虚拟主机的IP信息:
VM Host-only IP address: 192.168.59.103

然后,你就可以通过SSH工具连入虚拟机了:
Way One:Git Bash

logical_mind@LOGICAL_MIND-PC ~
$ ssh docker@192.168.59.103
The authenticity of host '192.168.59.103 (192.168.59.103)' can't be established.

ECDSA key fingerprint is 53:76:cc:fa:00:bf:7a:5a:96:e6:40:7c:dc:17:97:e5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.59.103' (ECDSA) to the list of known hosts.
docker@192.168.59.103's password:
                        ##        .
                  ## ## ##       ==
               ## ## ## ##      ===
           /""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
           \______ o          __/
             \    \        __/
              \____\______/
 _                 _   ____     _            _
| |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   <  __/ |
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
Boot2Docker version 1.4.0, build master : 69cf398 - Fri Dec 12 01:15:02 UTC 2014

Docker version 1.4.0, build 4595d4f
docker@boot2docker:~$ hostname
boot2docker
docker@boot2docker:~$ ifconfig
docker0   Link encap:Ethernet  HWaddr 56:84:7A:FE:97:99
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth0      Link encap:Ethernet  HWaddr 08:00:27:09:D1:FF
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe09:d1ff/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:289 errors:0 dropped:0 overruns:0 frame:0
          TX packets:192 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:42339 (41.3 KiB)  TX bytes:38390 (37.4 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:B4:8A:A6
          inet addr:192.168.59.103  Bcast:192.168.59.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feb4:8aa6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:198 errors:0 dropped:0 overruns:0 frame:0
          TX packets:49 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:24264 (23.6 KiB)  TX bytes:6984 (6.8 KiB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:48 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:3456 (3.3 KiB)  TX bytes:3456 (3.3 KiB)

docker@boot2docker:~$ df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                    1.8G    205.1M      1.6G  11% /
tmpfs                     1.8G    205.1M      1.6G  11% /
tmpfs                  1004.0M         0   1004.0M   0% /dev/shm
/dev/sda1                18.2G     83.3M     17.1G   0% /mnt/sda1
cgroup                 1004.0M         0   1004.0M   0% /sys/fs/cgroup
none                    238.4G    205.3G     33.0G  86% /c/Users
/dev/sda1                18.2G     83.3M     17.1G   0% /mnt/sda1/var/lib/docker
/aufs
docker@boot2docker:~$ exit
Connection to 192.168.59.103 closed.

logical_mind@LOGICAL_MIND-PC ~
$

如上所示,通过命令“ssh docker@192.168.59.103”,你可以以docker用户连入Docker所在的虚拟机,该用户的默认密码为:tcuser。

通过其他的终端工具连入也是如上所示的步骤,只需要提供正确的连入信息即可,它们如下(在我的当前环境中,不同的环境下也许不同,需要“boot2docker up -v”的反馈日志中具体确认):
IP:192.168.59.103
用户:docker
密码:tcuser

————————————————————————————————————————
Ending。

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒