Create a container image for Docker-in-Docker

“Docker-in-docker” is an often useful technique to help running multiple instances of container clusters (e.g. swarm services, docker-compose) on the same container host. It consists of:

- A conventional container image with docker server daemon and client utilities.
- A privileged container running the image, which has its entrypoint script to start the nested docker server daemon.
- Other techniques applied optionally to enhance the server daemon performance.

Let’s build the container image. First, prepare a utility script called `modprobe`:

#!/bin/sh
set -eu

# “modprobe” without modprobe: https://twitter.com/lucabruno/status/902934379835662336
for module; do
if [ “${module#-}” = “$module” ]; then
ip link show “$module” >/dev/null 2>&1 || true
fi…

About

Howard (Houzuo) Guo | HZGL

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store