我正在使用Windows 10
我已经安装了Virtual Box
在虚拟Box中我安装了Ubuntu,其网络设置为Bridge Network
我正在使用Docker Toolbox for Windows启动Docker
在Docker中我有Mongodb容器在默认端口
运行我正在虚拟盒中安装的Ubuntu中进行所有开发工作
这是我的终端日志
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default * virtualbox Running tcp://192.168.99.100:2376 v17.06.0-ce
$ docker-machine env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="C:\Users\test\.docker\machine\machines\default"
export DOCKER_MACHINE_NAME="default"
export COMPOSE_CONVERT_WINDOWS_PATHS="true"
# Run this command to configure your shell:
# eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
77427d4fc49b mongo "/bin/sh -c '/usr/..." About an hour ago Up 45 minutes mongo
问题是我不知道如何连接到这个运行MongoDB的容器全局说来自在Virtual Box上运行的Ubuntu
修改1:
来自Ubuntu的终端日志
test@test-VirtualBox:~$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:e1:c8:be brd ff:ff:ff:ff:ff:ff
inet 192.168.1.27/24 brd 192.168.1.255 scope global dynamic enp0s3
valid_lft 78034sec preferred_lft 78034sec
inet6 fe80::2ae9:9e0c:d9a3:f044/64 scope link
valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:3d:79:a8:7f brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 scope global docker0
valid_lft forever preferred_lft forever