# Docker network changes ip after reboot

**URL:** <https://forums.docker.com/t/docker-network-changes-ip-after-reboot/103812>\
**Category:** General\
**Tags:** docker\
**Created:** [January 31, 2021, 3:25pm UTC](https://forums.docker.com/t/docker-network-changes-ip-after-reboot/103812 "2021-01-31T15:25:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nygage](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/nygage/32/29331_2.png) [@nygage](https://forums.docker.com/u/nygage)\
**Post date:** [January 31, 2021, 3:25pm UTC](https://forums.docker.com/t/docker-network-changes-ip-after-reboot/103812/1 "2021-01-31T15:25:06Z")

</div>

Hello! I’m having a problem when running networks in my host. I create a network using

> ```
> docker network create name
> 
> ```

After that I added the containers to the network by compose.yml, all works great, i’ve different containers in the networks and all can communicate between them and with the host, but after a docker service reboot or a host machine reboot is when the problem comes. Just after the reboot if i put ifconfig on the host, i obtained the correct config to the network

```
br-93aeb64e21d1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet 172.18.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
        inet6 fe80::42:a4ff:fe86:bce prefixlen 64 scopeid 0x20<link>
        ether 02:42:a4:86:0b:ce txqueuelen 0 (Ethernet)
        RX packets 436 bytes 12208 (11.9 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 1090 bytes 369287 (360.6 KiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

```

But after some seconds if i rerun ifconfig, i obtain this:

```
br-93aeb64e21d1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet 169.254.251.214 netmask 255.255.0.0 broadcast 169.254.255.255
        inet6 fe80::42:a4ff:fe86:bce prefixlen 64 scopeid 0x20<link>
        ether 02:42:a4:86:0b:ce txqueuelen 0 (Ethernet)
        RX packets 3630 bytes 160808 (157.0 KiB)
        RX errors 0 dropped 0 overruns 0 frame 0
        TX packets 19000 bytes 26628297 (25.3 MiB)
        TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

```

The ip has changed, and the containers are isolated of the host and it does not have connection to external network.

This is the docker version I have

> ```
> Version: 17.05.0-ce
> API version: 1.29 (minimum version 1.12)
> 
> ```

I’m running it on a terramaster NAS so I cant update the version.

What can be happening?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![emadelbaih](https://avatars.discourse-cdn.com/v4/letter/e/e5b9ba/32.png) [@emadelbaih](https://forums.docker.com/u/emadelbaih)\
**Post date:** [January 31, 2021, 8:58pm UTC](https://forums.docker.com/t/docker-network-changes-ip-after-reboot/103812/2 "2021-01-31T20:58:36Z")

</div>

# Stop and disable dhcpcd daemon on system boot since we going to start it manually with /etc/rc.local

# NB: we do so, cause ‘docker’ when building or running a container sets up a ‘bridge’ interface which interferes ‘failover’

systemctl stop dhcpcd  
systemctl disable dhcpcd

# Start dhcpcd daemon on each interface we are interested in

dhcpcd eth0  
dhcpcd eth1  
dhcpcd wlan0

# Start dhcpcd daemon on every reboot

sed -i -e ‘s/^exit 0$//g’ /etc/rc.local  
echo “dhcpcd eth0” \>\> /etc/rc.local  
echo “dhcpcd eth1” \>\> /etc/rc.local  
echo “dhcpcd wlan0” \>\> /etc/rc.local  
echo “” \>\> /etc/rc.local  
echo “exit 0” \>\> /etc/rc.local

```auto
Also DNS servers for docker (probably, not necessary)

cat >> /etc/docker/daemon.json << EOF
{
    "dns": ["8.8.8.8", "8.8.4.4"]
}
EOF
service docker restart
```

---

<div class="post-metadata">

**Author:** ![nygage](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/nygage/32/29331_2.png) [@nygage](https://forums.docker.com/u/nygage)\
**Post date:** [February 9, 2021, 11:25am UTC](https://forums.docker.com/t/docker-network-changes-ip-after-reboot/103812/3 "2021-02-09T11:25:51Z")

</div>

That was! Thanks a lot!
