Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker starting container throws cannot assign requested address error

I have a ubuntu 12.04 virtual box configured on MAC OS host. Docker is on 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.

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
like image 798
connectwithpalaniappan Avatar asked Oct 31 '22 22:10

connectwithpalaniappan


1 Answers

I think you are using the -p option incorrectly.

-p, --publish=[] Publish a container's port to the host format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort

It looks like you are trying to set the IP of the container where you should have the host 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.

I do not think you can Set the container IP.

like image 185
grag42 Avatar answered Nov 03 '22 11:11

grag42