I am starting a docker container using ‘docker run’ on Ubuntu 20.04. I have set the ‘–restart’ option to ‘unless-stopped’ for the ‘docker run’ command. The container restarts automatically if it exits, as expected. However, if I reboot the computer, the docker container does restart as expected but a UI application that is part of the container doesn’t start. If I restart the container, the UI application starts as expected. This issue is seen on multiple computers although not on one other computer.
My guess is that there is a race condition and the docker container on reboot starts before the graphics subsystem on the host is fully initialized i.e. the X server. Is there any way to delay the container restart on reboot to wait on the X server? Alternatively, is there a way I can query from within the docker if the X server is running? I have found ways to query this from the host but not from within the docker.