Reputation: 105
I have a docker linked to a bridge with IP address 192.168.150.1/24
.
Once I create the docker instance from a docker image it gets an IP address, 192.168.150.2
, but according to my requirement, this IP address, 192.168.150.2
, must be reserved since I want to use it for some other thing.
Now, I want to change the IP address of this docker instance as 192.168.150.3
. Is it possible to do? if so how? Please, help.
Upvotes: 5
Views: 15139
Reputation: 113
You can specify a particular IP address when you define the port mapping, for example
-p 192.168.150.3:6379:6379
Upvotes: 2
Reputation: 2895
here is another option, try to use -b bridge
option to use a certain ip range, like for instance -b br0=192.168.150.3/24
here is more complete example configure docker bridge network
Upvotes: 0
Reputation: 433
You will have to first detach the container from the custom network and the connect it back by providing the ip.
You can follow the following steps :
docker network disconnect [OPTIONS] NETWORK CONTAINER
docker network connect --ip 192.168.150.3 NETWORK CONTAINER
Upvotes: 19