When stopping a container one way or another, like by Ctrl+C or docker stop, Docker sends SIGTERM to the process by default. If the first process (PID = 1) on the container is not a proper init process, the termination may take a long time to be done. It's because processes running as PID 1 are treated differently than usual ones. In Linux, a process running as PID 1 ignores any signal unless the process implements signal handlers on its own.
Docker is an important tool for running web applications in both production and development environments nowadays. Actually, it can also be used for running desktop applications. That means you can take advantage of Docker's mobility even on the desktop. However, there are some tricks to make that work well. In short, you have to enable applications inside containers to use some resources on the host machine. Using X11 via Unix Socket As you may know, X11 originally supports remote use and it can be accessed via TCP or Unix Domain sockets.
You have to use proper init process when you create a docker image. Running a process on docker without it might lead unexpected results. Today, I'll explain about that. The “init” Process and Orphans On a Linux system, the process which has PID 1 is the root of the process tree. It is called “init”. The default signal handlers of the init process is different from other ordinary processes. And the init process has a special responsibility.