虚拟机内的 docker 上不了网,只能 ping 通虚拟机的 ip192网段的

安装报错 · yyyejunyu · 于 6年前 发布 · 2032 次阅读

网上查了下,说要设置路由什么的,但是 docker 里什么命令都说没有,求指教

共收到 3 条回复
Fecmall#16年前 0 个赞

我也不了解这个,帮不上忙,你自己搜索资料解决吧。

wubuyun#26年前 0 个赞

hp@hp-HP-Compaq-6530b:~/yii2_fecshop_docker-master$ sudo docker-compose exec php bash root@b49fa6b1f233:/var/www/html# apt-get update Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB] Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://deb.debian.org jessie Release.gpg [2434 B]
Get:4 http://security.debian.org jessie/updates/main amd64 Packages [644 kB]
Get:5 http://deb.debian.org jessie Release [148 kB]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.1 kB]
Get:7 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 10.1 MB in 36s (274 kB/s)
Reading package lists... Done root@b49fa6b1f233:/var/www/html# apt-get install net-tools

Reading package lists... Done Building dependency tree
Reading state information... Done The following NEW packages will be installed: net-tools 0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded. Need to get 225 kB of archives. After this operation, 803 kB of additional disk space will be used. Get:1 http://deb.debian.org/debian/ jessie/main net-tools amd64 1.60-26+b1 [225 kB] Fetched 225 kB in 4s (47.0 kB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package net-tools. (Reading database ... 14044 files and directories currently installed.) Preparing to unpack .../net-tools_1.60-26+b1_amd64.deb ... Unpacking net-tools (1.60-26+b1) ... Setting up net-tools (1.60-26+b1) ... root@b49fa6b1f233:/var/www/html# ifconfig eth0 Link encap:Ethernet HWaddr 02:42:ac:12:00:04

      inet addr:172.18.0.4  Bcast:0.0.0.0  Mask:255.255.0.0
      inet6 addr: fe80::42:acff:fe12:4/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:7563 errors:0 dropped:0 overruns:0 frame:0
      TX packets:4035 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:11022142 (10.5 MiB)  TX bytes:283573 (276.9 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:20 errors:0 dropped:0 overruns:0 frame:0
      TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:1980 (1.9 KiB)  TX bytes:1980 (1.9 KiB)

root@b49fa6b1f233:/var/www/html#

wubuyun#36年前 0 个赞

adding RUN apt-get install -y net-tools to your Dockerfile.

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics