Docker containers did not start automatically after reboot

Hello.
I got some docker containers and bind specific ip addresses to them.
Everything works fine until I reboot the server.
After reboot - docker container did not start automatically, and I see next error:

“Error”: “driver failed programming external connectivity on endpoint vpn_tcp_1 (cdc3165190402c0fb8508be246cf9c0e51cd3240f802470e1e211ad644dc5237): Error starting userland proxy: listen tcp4 10.10.10.10:9536: bind: cannot assign requested address”

And if I did service docker restart - they all started.
So, I think the problem is that docker starts too fast, before the network does, and when it tries to run the container - there is no ip address and it fails.
So, the question is, how can I fix it ?

How did you install Docker and on what operating system exactly?

via apt, ubuntu 22.04, default flow
I try to edit systemd unit changing Wants to Requires for network-online.target - but no luck
Then I try add delay with drop-in:

[Service]
ExecStartPre=/bin/sleep 30

and this helped, but I think this is not right way.

Here is docker info:

Client: Docker Engine - Community
Version: 25.0.2
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.5
Path: /usr/libexec/docker/cli-plugins/docker-compose

Server:
Containers: 21
Running: 21
Paused: 0
Stopped: 0
Images: 6
Server Version: 25.0.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.15.0-92-generic
Operating System: Ubuntu 22.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.52GiB
Name: ttd01
ID: 8ed531f4-0243-4f6c-b028-fcb2adc2e125
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

That is not how “exactly” you installed, just the package manager and I don’t know what you consider the “default flow”. If you followed a documentation or tutorial, please share the link.

The output of the following command could help too:

dpkg -l | grep docker

Install from this manual - Install Docker Engine on Ubuntu | Docker Docs

ii docker-buildx-plugin 0.12.1-1~ubuntu.22.04~jammy amd64 Docker Buildx cli plugin.
ii docker-ce 5:25.0.2-1~ubuntu.22.04~jammy amd64 Docker: the open-source application container engine
ii docker-ce-cli 5:25.0.2-1~ubuntu.22.04~jammy amd64 Docker CLI: the open-source application container engine
ii docker-ce-rootless-extras 5:25.0.2-1~ubuntu.22.04~jammy amd64 Rootless support for Docker.
ii docker-compose-plugin 2.24.5-1~ubuntu.22.04~jammy amd64 Docker Compose (V2) plugin for the Docker CLI.

Then one more idea:

You could check your network configuration if you have optional networks.

There are some other discussions about similar issues. The above topic just shows one that I think I had once, although not with Docker.

Great question @zeronights :slight_smile:

I am just working on a new bare metal server setup, using ansible and creating a Wireguard mesh network between the servers, so this will be very relevant for me, too :raising_hand_man: