docker-management-container

Docker Management Container

The Docker Management Container (or DMC for short) contains a number of plugins and services that are designed to make it easy to create, test, deploy and manage infrastructures. For more information also take a look at our Blog.

How does the DMC work?

The DMC provides a Dockerfile template (from modular setup) that creates the Dockerfile with the desired tools and versions through a file and script. This Dockerfile is then used for the actual build of the container. The Dockerfile itself does not need to be kept, but is created and discarded after the build of the Dockerfile.

The DMC uses the wakemeops as base setup, for more information about wakemeops look at the docs.

Try

For a quick overview and test of the DMC, we have created images based on the minimal and full examples that can be used directly.

# minimal
docker run ghcr.io/telekom-mms/dmc:min

# full
docker run ghcr.io/telekom-mms/dmc:full

Usage

Setup and Configuration

Setup plugins, services, tools, versions and configuration over file with yaml syntax.

touch build.yaml

Image

The DMC uses the wakemeops image as base image.

Image ARG

Base

Basic Setup of the DMC.

Tools

Tools to be installed within the DMC.

Tools ARG

Tool Config

Extension of installed tools.

Tool Config ARG

Post Build Config

System configuration and further setups to finish the DMC build.

Post Build Config ARG

Build Dockerfile

To create the Dockerfile from Template you have simply to run the following steps.

  1. create build.yaml with your needed settings
  2. run the script render.sh
  3. build Docker Image

render.sh

The build script will create the Dockerfile from template.d with your settings from build.yaml.

sh render.sh .

Build Image

docker image build -t dmc:latest .

Examples for build within CI Pipelines can be found under examples/pipeline.

Run Image

local

To run the Docker Management Container your system must have Docker or Podman installed.

docker run -ti dmc:latest
mount volumes

You can mount your code or git repository into the container. This way you can work with your favorite editor and test the changes directly in the DMC.

Example:

docker run -ti --env-file .docker_env -v${HOME}/git/service:/service -w /service dmc:latest
run the image with your local user and environment

If you mount your repositories to the DMC you might want to run it with your local user and environment

This should give you a few benefits:

Example:

docker run --rm -ti --hostname dmc \
  `# you can include your services environment variables if you like` \
  --env-file ~/service/.docker_env \
  \
  `# run as local user and make the container aware of users + groups` \
  -v /etc/passwd:/etc/passwd:ro \
  -v /etc/group:/etc/group:ro \
  --user "$(id -u):$(id -g)" \
  \
  `# provide ssh socket to the container for ansible to use` \
  -e 'SSH_AUTH_SOCK=/.ssh_auth' \
  -v ${SSH_AUTH_SOCK}:/.ssh_auth \
  \
  `# mount home and use the service subdirectory as workdir` \
  -v ${HOME}:${HOME} \
  -w ${HOME}/service \
  \
  dmc:latest
mount volumes with docker volume bindfs as root

With the Docker volume plugin for bindfs, you’re able to mount a given path and remap its owner and group. This way you can be root inside the container while still mapping your home-directory inside the container (to /root) and using it without permission problems.

# create the docker volume
docker volume create -d lebokus/bindfs -o sourcePath=$PWD -o map=$(id -u)/0:@$(id -g)/@0 dmcvolume
# run your dmc with the volume
docker run -it --user root -v dmcvolume:/root/ dmc:latest

Included renovate preset

We provide a renovate-preset to include in your configuration. If you use it renovate can update the versions in your build.yaml

Include it like this:

{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": [
    "config:base",
    "github>T-Systems-MMS/docker-management-container"
  ],
}

Change your build.yaml like this to use it:

packages:
  # renovate: datasource=repology depName=ubuntu_22_04/ansible versioning=loose
  - ansible=2.10.7+merged+base+2.10.8+dfsg-1

  ansible:
    collections:
      # renovate: datasource=galaxy-collection depName=telekom_mms.acme
      - telekom_mms.acme=2.3.1

Migration

With Version 2.0.0 there’s a breaking change in the configuration and usage of the DMC. To support the migration we provide a script to migrate from the old .docker_build to the new build.yaml.

migrate.sh

sh migrate.sh .

Examples

Examples for the build.yaml could be found under examples:

Others

Feedback, suggestions for improvement and expansion, and of course collaboration are expressly desired.