Code Monkey home page Code Monkey logo

dind's Introduction

neocrym/dind -- An Ubuntu-based Docker-in-Docker image with systemd

This is a Docker installation based on Ubuntu. It installs systemd and Docker.

This image is used for running Docker containers via an isolated Docker daemon. This is useful for testing code that launches Docker containers without giving complete access to the Docker daemon on the host machine.

If you are fine with giving your code access to your host machine's Docker socket, you might instead consider binding your host's Docker socket into your container. Jérôme Petazzoni further in his blog post comparing Docker-in-Docker to bind-mounting the Docker socket.

Usage

To use this image, you will need to use the --privileged flag. Note that this effectively gives this container root access to your machine. At this time of writing, this container will not work on Docker Swarm because Swarm Mode does not support the --privileged flag for containers.

You should also mount /run and /run/lock as tmpfs mounts. The container's /sys/fs/cgroup should be a read-only mount to the same directory on the host. You should also create a Docker volume at /var/lib/docker to persist Docker state across container runs. Do not have multiple containers share this volume.

The Docker Compose for the above configuration looks like:

version: "3.9"

services:
  dind:
    image: jamesmishra/dind
    privileged: true
    volumes:
      - type: tmpfs
        target: /run
      - type: tmpfs
        target: /run/lock
      - type: bind
        source: /sys/fs/cgroup
        target: /sys/fs/cgroup
        read_only: true
      - type: volume
        source: dind_volume
        target: /var/lib/docker

volumes:
  dind_volume:

Overriding the entrypoint

If you are creating a new image based on this image, you might want to override the image's entrypoint to run commands upon container startup.

To make sure that systemd starts, make sure your container entrypoint ends by exec-ing /lib/systemd/systemd. As a bash script, this looks like:

#!/bin/bash
echo "Your code goes here."
exec /lib/systemd/systemd

Credits

This image takes heavy inspiration from cruizba/ubuntu-dind, docker/dind and jrei/systemd-ubuntu.

dind's People

Contributors

jamesmishra avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.