Running Ubuntu with Docker

Gaurav Gandhi
2 min readSep 27, 2019

--

When Docker starts a container (in our case Ubuntu), it only runs the command we provided or default /bin/bash. It doesn’t go through regular system startup, because it’s not actually system startup, it just executes the given command and dies.

The problem comes when we want something to be running instead of just executing and exiting. In other words, if you want to use docker as lambda function than Ubuntu base image works perfectly.
But when you want to use it as a server, then we have to tweak a little bit.

Ubuntu is designed to be running with real hardware or virtual hardware but not isolated environment like Docker. When we start docker and ask to execute the command (CMD), that command becomes the first process, aka the init process. But it doesn’t handle the extra responsibility of reaping orphaned child processes.

As a result, it will become filled with zombie processes over time. When we execute docker stop on that container, it sends SIGTERM to the init process, and as its regular process, it will terminate itself. Than kernel will force-fully kill zombie process and resulting in possible file corruptions.

Another major issue is that we won’t be getting any system logs as `syslog` daemon won’t be running by default.

Now patching above all issues might be tedious and time-consuming, but what if we get fully updated and patched Ubuntu base image?
I present you the base image-docker by Phusion.

It has patched all the above issues as well as many more. Check out more information on their GitHub wiki page(https://github.com/phusion/baseimage-docker)

--

--

Gaurav Gandhi

10+ yrs exp. in software dev. Highly versatile and adaptable, learns new tech quickly to deliver top-notch results.