How to change the Docker subnet?

Asked

Viewed 2,508 times

2

I am in a network that uses the IP range 172.17.42.1, unfortunately the same as Docker. Because of this I can no longer access my local network because the two networks conflict. Docker IP address can be changed?

1 answer

2


This is a common problem and the solution is simple. First stop the Docker service:

sudo service docker stop

To see Nat routing information, run the command:

iptables -t nat -F POSTROUTING

Disconnect and remove the connection docker0:

ip link set dev docker0 down
ip addr del 172.17.42.1/16 dev docker0

Now add a new connection to docker0 and lift that connection:

ip addr add 192.168.10.1/24 dev docker0
ip link set dev docker0 up

Run the command below to view connection information docker0:

ip addr show docker0

Initialize the Docker service:

sudo service docker start

You will probably now be able to connect to your local network.

To view more information about your network, run the command below:

iptables -t nat -L -n
  • 1

    When we use Docker on MAC OSX or Windows there may be a network conflict problem similar to this, but in Virtual Box. In this case we can use the command VBoxManage as in the example: VBoxManage modifyvm "Win7-64bits" --natnet1 "192.168.199.0/24" The complete solution can be seen in http://joao-parana.com.br/blog/interface-bridge-no-boot2docker/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.