This post details how to package and deploy software with Docker. The example uses Merecat httpd on Alpine Linux. Try it out with:

docker pull troglobit/merecat

See for details on how to run Merecat httpd in production.

The software I’ve chosen for this exercise is Merecat httpd, and the reason is simple: we needed a really small web front-end to the FTP server at work and Debian has removed Boa from its repo, which also means it’s missing from Ubuntu these days.

If you’ve not yet installed Docker, do so now.

sudo apt install
sudo adduser $LOGNAME docker

NOTE: Remember to log out and in again to activate the new group settings before continuing below.

Merecat comes with a Dockerfile, so all we need to do to is build the image and flatten it before we deploy. Start by cloning the repo:

git clone
cd merecat/
docker build .
Successfully built c87dd09084a3

Take note of the resulting image hash, here c87dd09084a3. You can also find this with the docker images command.

Now, take it for a spin. Allow your host’s port 80 (HTTP) to be forwarded to the container’s port 80:

docker run -dit -p 80:80 c87dd09084a3
www-browser localhost

Another hash is printed, this time for the running container, which can also be seen using the docker ps command.

Finally, it’s time to flatten the container:

docker export d98583cb31c9 | docker import - troglobit/merecat:latest

Notice this size difference of between d98583cb31c9 and the flattnened image, run docker images:

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
troglobit/merecat   latest              1764df1eb990        5 seconds ago       4.271 MB
<none>              <none>              c87dd09084a3        29 minutes ago      192.4 MB
alpine              3.5                 37c7be7a096b        3 days ago          3.991 MB

We now have our production image. Kill the currently running “template” container and remove its image before continuing:

docker kill d98583cb31c9
docker rmi -f c87dd09084a3

Let’s check the production image, here I export my FTP directory to the container’s WWW dir. Notice how the entry point is lost after flattening, so we have to provide the full command, or write a new Dockerfile:

docker run -dit -v /srv/ftp:/var/www -p 80:80 troglobit/merecat merecat -n /var/www
www-browser localhost

You should now see the FTP server contents, provided of course your host has an /srv/ftp directory.