postgresql Docker 启动容器抛出无法分配请求的地址错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24087858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Docker starting container throws cannot assign requested address error
提问by Silent_Pal
I have a ubuntu 12.04 virtual box configured on MAC OS host. Docker is on ubuntu
我在 MAC OS 主机上配置了一个 ubuntu 12.04 虚拟机。Docker 在 ubuntu 上
My ethernet configuration (bridged adapter) is
我的以太网配置(桥接适配器)是
eth2 Link encap:Ethernet HWaddr 08:00:27:f9:8f:77
inet addr:172.16.0.11 Bcast:172.16.255.255 Mask:255.255.0.0
inet6 addr: fe80::a00:27ff:fef9:8f77/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:685 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:128864 (128.8 KB)
when I try to start a postgresql container, get the below error.
当我尝试启动 postgresql 容器时,出现以下错误。
sudo docker run -d -name="postgresql" -p 172.17.0.2:5432:5432 -v /data/sql:/data -e USER="username" -e DB="dbname" -e PASS="passwordname" paintedfox/postgresql
Warning: '-name' is deprecated, it will be replaced by '--name' soon. See usage.
WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : [8.8.8.8 8.8.4.4]
596355cf67dfe807f4e18cf341b3672eb0ab5e258f3fbbe332405ec101ea6949
2014/06/06 10:41:02 Error: Cannot start container 596355cf67dfe807f4e18cf341b3672eb0ab5e258f3fbbe332405ec101ea6949: listen tcp 172.17.0.2:5432: bind: cannot assign requested address
回答by grag42
I think you are using the -p option incorrectly.
我认为您错误地使用了 -p 选项。
-p, --publish=[] Publish a container's port to the host format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort
-p, --publish=[] 将容器的端口发布到主机格式:ip:hostPort:containerPort | ip::containerPort | 主机端口:容器端口
It looks like you are trying to set the IP of the container where you should have the host IP
看起来您正在尝试设置应该拥有主机 IP 的容器的 IP
sudo docker run -d -name="postgresql" -p 5432:5432 -v /data/sql:/data -e USER="username" -e DB="dbname" -e PASS="passwordname" paintedfox/postgresql
or
或者
sudo docker run -d -name="postgresql" -p 172.16.0.11:5432:5432 -v /data/sql:/data -e USER="username" -e DB="dbname" -e PASS="passwordname" paintedfox/postgresql
Will publish the port 5432 to your system's port 5432.
将端口 5432 发布到您系统的端口 5432。
I do not think you can Set the container IP.
我认为您无法设置容器 IP。