简体   繁体   English

更改docker的IP地址

[英]change ip address for docker

I have a problem with docker: I try to create a container but when I execute 我有一个docker问题:我尝试创建一个容器,但是当我执行时

docker run -i -t base /bin/bash   # everything doing good 
aptitude update

I'm getting this error message: 我收到此错误消息:

Temporary failure resolving 'archive.ubuntu.com' 临时故障解决'archive.ubuntu.com'

I try to change the IP address of docker0 but all time I fail. 我尝试更改docker0的IP地址但是我一直都失败了。

The IP address on my linux 我的linux上的IP地址

 docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 7a:3c:fa:08:73:94 brd ff:ff:ff:ff:ff:ff
    inet 172.16.42.1

My resolv.conf: 我的resolv.conf:

# Generated by NetworkManager
nameserver 213.244.0.15
nameserver 213.244.0.16
nameserver 8.8.8.8

from https://github.com/dotcloud/docker/issues/866#issuecomment-19218300 : 来自https://github.com/dotcloud/docker/issues/866#issuecomment-19218300

You could try to reset all the networking/iptables: 您可以尝试重置所有网络/ iptables:

pkill docker
iptables -t nat -F
ifconfig docker0 down
brctl delbr docker0
docker -d

It will force docker to recreate the bridge and reinit all the network rules. 它将强制docker重新创建网桥并重新启动所有网络规则。

刚看到我的docker0接口关闭了,我执行了sudo /etc/init.d/docker restart ,它sudo /etc/init.d/docker restart ,我的docker再次工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM