Three useful questions about Docker

When trying to wrap my head around Docker, the following three Stackoverflow questions helped me the most. I have included a summary of the answer, together with my comments.

What is the relationship between the host system and the container base image?

The simple answer: All that is shared between the host system and a container is the kernel. The container sees only the base file system provided by within the image, and the container cannot access files on the host system. This, except when you bind mount the host file system into the container, see below.

There is no requirement, nor a need, for matching the host OS with the OS of the docker containers – AFAIK there is no performance gain in doing so. This implies that you can run a CentOS container on an Ubuntu host OS, and it will work fine. You may choose a base image that fits you best, though you will want one that receives security updates.

How to deal with persistent storage (e.g. databases) in docker?

This question naturally arise, as every service is in an isolated container. The answer is: All data is by default stored in the container. If you need to persist storage outside, use either a dedicated data volume container, or bind mount a host directory to the container. This is done with a command line argument, when starting the container.

Can you run GUI apps in a docker container?

You can indeed run GUI apps as Docker containers, and there are several ways to do it. The simplest way is to install X-Windows in the container, and open for VNC connections.

Stackoverflow is a goldmine for learning about technology, or just trying to solve a programming related problem. Here you can find all the Docker Q&A you will ever need.