项目作者: tuan-l

项目描述 :
Docker-in-docker
高级语言: Dockerfile
项目地址: git://github.com/tuan-l/dind.git
创建时间: 2020-09-19T13:37:19Z
项目社区:https://github.com/tuan-l/dind

开源协议:GNU General Public License v3.0

下载


Docker-in-docker

This repository is used to keep what I have learned about docker-in-docker.

Prerequisites

First of all, you have to have the docker-ce installed on your system, follow the instructions below to install docker and docker-compose:

  1. ## Install docker rootless
  2. $ curl -fsSL https://get.docker.com/rootless | sh
  3. $ sudo apt update && apt install -y docker-compose
  4. ## For Alpine Linux users
  5. $ sudo apk update && sudo apk add docker docker-compose
  1. ## Add current user to docker group
  2. $ sudo usermod -aG docker $USER
  3. ## For Alpine Linux users
  4. $ sudo addgroup $USER docker

After then, edit .env file if needed. This is optional. Default values are:

  1. USER_ID=dind
  2. USER_PW=password
  3. PORT=1022

these are username and password for the user you will use to manipulate with the experiment. Both root and USER_ID users use the same password USER_PW. PORT is used to forward SSH port to.

Experiment

If you want to run the experiment right away, modify docker-compose.yml file with following settings:

  1. version: "3"
  2. services:
  3. dind:
  4. image: docker.pkg.github.com/tuan-l/dind/dind:1.0
  5. container_name: docker-in-docker
  6. ports:
  7. - "${PORT}:22" # ssh port
  8. working_dir: /workspace
  9. volumes:
  10. - "/var/run/docker.sock:/var/run/docker.sock"
  11. - "./files:/workspace/"

Run the following commands to build and run the experiment:

  1. docker-compose up

SSH into main container by the following commands:

  1. # user is the username you have defined before
  2. $ ssh user@localhost -p 1022

then type in your password to login.

Inside this container you could working with docker as normally, the only prolem we face here is docker volume, you could not bind mount correctly in nested containers.

You also could use Tera Term, PuTTy, WinSCP or FileZilla to manipulate with the system.