Docker Community Forums

Share and learn in the Docker community.

How to keep a container running after disconnecting session?

Hello,

We have a GUI with business code running with Docker and X11.
No problem about it.

The code is similar as https://blog.jessfraz.com/post/docker-containers-on-the-desktop/

docker run -d \
    -v /tmp/.X11-unix:/tmp/.X11-unix \ # mount the X11 socket
    -e DISPLAY=unix$DISPLAY \ # pass the display
    --name homebrew-app \
    homebrew/myapp:1.0.0

The UI is right executed but when we close the session, the X11 is destroyed too and the container is destroyed.

If we use a Restart Policy with unless-stopped, we solve a part of the problem.
Because of the container is right recreated when an user will be logged but it is a new one… we do not want a new one but the previous one.

Can you skip this problem with X11 background solution ?
If no possible, we will put the business code into another container running in background.

Thanks a lot.
Nicolas