How to change the subnet of Docker?

2

I'm on 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. Is it possible to change the IP address of Docker?

    
asked by anonymous 13.09.2015 / 02:41

1 answer

2

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

sudo service docker stop

To see information about nat routing, run the command:

iptables -t nat -F POSTROUTING

Disconnect and remove the docker0 connection:

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 this connection:

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

Run the command below to view information about the docker0 connection:

ip addr show docker0

Initialize the Docker service:

sudo service docker start

You may 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
    
13.09.2015 / 02:41