Docker Community Forums

Share and learn in the Docker community.

Raspbian Docker-Compose Static-IP not working

Hello everyone,

i have only been working with Docker for a short time. Currently, I’m trying to create an service with openvpn. To create the service I used docker-compose with version 2.4 (defined in the Yaml).

For routing purposes I want to assign a static-ip to the container. The network is a bridge-network with the following specifications:

  • subnet:
  • ip-address:
  • ip-range:
  • gateway:

When I execute the command “ip addr show” in the container by the Dockerfile, it gaves me the ip “172.17.x.x” as output and not the static ip. A ping is also not successfull. But the network is successfully created.

My docker-compose.yaml:

version: "2.4"
            driver: bridge 
            name: bridge_extern
                    driver: default 
                            - subnet:
            external: true
            build: .
            image: debian:latest
            hostname: openvpn-docker
            container_name: extern_openvpn
                    - NET_ADMIN
                    - NET_RAW
                    - "1194:1194"
                    - type: volume
                      source: openvpn_pki
                      target: /etc/openvpn/pki
                    - type: bind 
                      source: .
                      target: /media

Do you have an idea and can you please help me?

Thank you and best regards

Just a question rather than answering your question: did you use TAB for indentation? I understand this is not working and the space bar should be used instead (twice for one indentation)

Hi reneth,

thank you for your answer. Yes, I am using TAB for indentation, but it works fine.

A couple of hours ago I have solved the problem myself. When executing a dockerfile, which is be parameterized in an docker-compose yaml-file, for every RUN-command in the dockerfile, a container is starting. In conclusion, the options in the docker-compose yaml-file take affect afterwards, after the dockerfile was executed completly.

Best regards

I think I’ve fixed it, it’s been three days and I think it would otherwise have broken by now but things are going well.

I checked /var/log/syslog and saw a couple suspicious looking things. One was a bunch of logs from dhcpcd that looked like:

dhcpcd[411]: eth0: pid 411 deleted route to
dhcpcd[411]: eth0: received approval for (that’s that device’s static IP)
dhcpcd[411]: eth0: adding route to
dhcpcd[411]: eth0: adding default route via

And a lot of other similar looking messages between eth0 and some other docker created network interfaces. Those messages were coming in around 20 per second for hours and hours. The log was absolutely spammed with them, like hundreds of thousands of those.

Then right around when the internet would cut out there would be several logs like this:

dhcpcd[411]: eth0: checksum failure from
What causes that checksum failure I’m not sure. That being said I searched for this and found some similar threads from other people were having similar issues and it came down to how the static IP was set in my case at least. Raspberry Pi OS lets you edit your network settings with a GUI. That GUI has a checkbox for “Automatically configure empty options” and I had left that checked and only filled out the IPv4 Address. That was always fine beforehand but for whatever reason since starting to use Docker that doesn’t seem to work.

I undid everything in that GUI and edited /etc/dhcpcd.conf instead like is suggested on the Raspberry Pi website’s instructions for setting a static IP and since then I’ve not had any issues on either of the two Raspberry Pi devices.