• This repository has been archived on 04/Jan/2022
  • Stars
    star
    105
  • Rank 316,786 (Top 7 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tiny Docker in Docker

Docker FROM scratch

Docker-in-Docker image based off of the empty image scratch. Only the bare minimum required files are included to make Docker run. This image weighs in around 25MB expanded.

Running

Overlay

# Daemon
docker run --name daemon --privileged -d rancher/docker

# Client
docker exec -it daemon docker ps

Aufs

# Daemon
docker run --name daemon --privileged -d rancher/docker daemon -s aufs

# Client
docker exec -it daemon docker ps

Embed in Custom Image

Since docker-from-scratch doesn't assume a base Linux distro it can be easily copied into an other image to add Docker-in-Docker capabilities

docker export $(docker create rancher/docker) > files.tar

cat > Dockerfile << EOF

FROM ubuntu
ADD files.tar /
ENTRYPOINT ["/usr/bin/dockerlaunch", "/usr/bin/docker"]
VOLUME /var/lib/docker
CMD ["daemon", "-s", "overlay"]

EOF

docker build -t custom-dind .

Graph Driver Compatibility

This image is really designed to run with overlay. Aufs is known to work but other graph drivers may not work properly or be missing userspace programs needed.

Seriously, Why?

This code and the supporting files were extracted out of RancherOS into a separate library and are still used by RancherOS. RancherOS runs Docker as the first process but before we can exec Docker we need to setup a minimal environment for Docker in which to run. Since RancherOS is executed by the kernel there is absolutely nothing setup in the system. At Rancher we wrote a small amount of code to setup all the required mounts and directories to launch Docker.

We moved this code out into a separate project for two reasons. First was simply that we wanted to clean up and modularize the RancherOS code base. Second is that we wanted to demonstrate clearly what exactly Docker requires from the Linux user space. For the most part Docker requires the standard mounts (/proc, /sys, /run, /var/run, etc) and the cgroup mounts in /sys/fs/cgroup plus the following programs/files:

/etc/ssl/certs/ca-certificates.crt
/usr/bin/modprobe
/usr/bin/iptables
/usr/bin/ssh
/usr/bin/xz
/usr/bin/git
/usr/bin/ps
/usr/libexec/git-core/git-clone
/usr/libexec/git-core/git-submodule
/usr/libexec/git-core/git-checkout

This list can be reduced to a bare minimum if you ignore certain features of Docker. A full description of why each program is needed is below.

File Description Can it be ignored
/etc/ssl/certs/ca-certificates.crt Used as the CA roots to validate SSL connections No
/usr/bin/modprobe Used to ensure that bridge, nf_nat, br_netfilter, aufs, or overlay modules are loaded. Additionally iptables loads kernel modules based on the configuration of the rules Yes, just load the modules from the host that you will need.
/usr/bin/iptables Docker uses IPtables to setup networking Yes, add --iptables=false to the docker -d command. Networking will have to be manually configured in this situation
/usr/bin/ssh Used by git to clone repos over SSH Yes, don't use git based Docker builds
/usr/bin/xz Used to extract legacy Docker images that were compressed with xz Yes, only use newer images. Most popular images are not based on xz
/usr/bin/git Used to do Docker builds from a git URL Yes, don't use git based Docker builds
/usr/bin/ps docker ps uses the host ps to get information about the running process in a container No
/usr/libexec/git-core/git-clone Used by git Yes, don't use git based Docker builds
/usr/libexec/git-core/git-submodule Used by git Yes, don't use git based Docker builds
/usr/libexec/git-core/git-checkout Used by git Yes, don't use git based Docker builds

Custom Bridge Name

If you want to run with a custom bridge name you must pass both --bip and -b as arguments. Normally this would be an error for Docker but in this situation the docker-from-scratch container will create the bridge device with the IP address specified and then old pass -b to Docker.

Troubleshooting

Zombies

If you are running containers with --pid=host you can get zombies. When you launch docker-from-scratch just add -e DOCKER_LAUNCH_REAP=true as a parameter to the docker run command to fix this.

Weird module loading errors

For various reasons Docker or iptables may try to load a kernel module. You can either manually load all the needed modules from the host or you can bind mount in the kernel modules by adding -v /lib/modules/$(uname -r)/lib/modules/$(uname -r) to your docker run command

Debug Logging

To enable debug logging on the startup of docker-from-scrach just add -e DOCKER_LAUNCH_DEBUG=true to the docker run command. For example:

docker run --name daemon --privileged -d -e DOCKER_LAUNCH_DEBUG=true rancher/docker

More Repositories

1

rancher

Complete container management platform
Go
22,538
star
2

os

Tiny Linux distro that runs the entire OS as Docker containers
Go
6,437
star
3

k3os

Purpose-built OS for Kubernetes, fully managed by Kubernetes.
Go
3,403
star
4

rke

Rancher Kubernetes Engine (RKE), an extremely simple, lightning fast Kubernetes distribution that runs entirely within containers.
Go
3,138
star
5

rio

Application Deployment Engine for Kubernetes
Go
2,282
star
6

local-path-provisioner

Dynamically provisioning persistent local storage with Kubernetes
Go
1,938
star
7

fleet

Deploy workloads from Git to large fleets of Kubernetes clusters
Go
1,450
star
8

convoy

A Docker volume plugin, managing persistent container volumes.
Go
1,308
star
9

rke2

Go
1,028
star
10

old-vm

(OBSOLETE) Package and Run Virtual Machines as Docker Containers
Go
646
star
11

ui

Rancher UI
JavaScript
587
star
12

cattle

Infrastructure orchestration engine for Rancher 1.x
Java
574
star
13

k3c

Lightweight local container engine for container development
Go
571
star
14

system-upgrade-controller

In your Kubernetes, upgrading your nodes
Go
502
star
15

dashboard

The Rancher UI
Vue
410
star
16

community-catalog

Catalog entries contributed by the community
Smarty
384
star
17

charts

Github based Helm Chart Index Repository providing charts crafted for Rancher Manager
Smarty
381
star
18

install-docker

Scripts for docker-machine to install a particular docker version
Shell
361
star
19

dapper

Docker build wrapper
Go
358
star
20

quickstart

HCL
357
star
21

cli

Rancher CLI
Go
331
star
22

terraform-provider-rke

Terraform provider plugin for deploy kubernetes cluster by RKE(Rancher Kubernetes Engine)
Go
328
star
23

opni

Multi Cluster Observability with AIOps
Go
323
star
24

kim

In ur kubernetes, buildin ur imagez
Go
323
star
25

trash

Minimalistic Go vendored code manager
Go
296
star
26

terraform-controller

Use K8s to Run Terraform
Go
290
star
27

remotedialer

HTTP in TCP in Websockets in HTTP in TCP, Tunnel all the things!
Go
255
star
28

elemental-toolkit

โ„๏ธ The toolkit to build, ship and maintain cloud-init driven Linux derivatives based on container images
Go
251
star
29

elemental

Elemental is an immutable Linux distribution built to run Rancher and its corresponding Kubernetes distributions RKE2 and k3s. It is built using the Elemental-toolkit
Go
228
star
30

terraform-provider-rancher2

Terraform Rancher2 provider
Go
222
star
31

rancher-compose

Docker compose compatible client to deploy to Rancher
Go
214
star
32

wrangler

Write controllers like a boss
Go
205
star
33

os-vagrant

Ruby
176
star
34

rancher-catalog

Smarty
155
star
35

docs

Documentation for Rancher products (for 2.0/new site)
SCSS
140
star
36

fleet-examples

Fleet usage examples
Shell
140
star
37

catalog-dockerfiles

Dockerfiles for Rancher Catalog containers
Shell
131
star
38

rancher-cleanup

Shell
125
star
39

api-spec

Specification for Rancher REST API implementation
121
star
40

k8s-intro-training

HTML
114
star
41

ansible-playbooks

Rancher 1.6 Installation. Doesn't support Rancher 2.0
Python
113
star
42

sherdock

Docker Image Manager
JavaScript
110
star
43

norman

APIs on APIs on APIs
Go
108
star
44

lb-controller

Load Balancer for Rancher services via ingress controllers backed up by a Load Balancer provider of choice
Go
97
star
45

pipeline

Go
96
star
46

k3k

Kubernetes in Kubernetes
Go
89
star
47

container-crontab

Simple cron runner for containers
Go
88
star
48

backup-restore-operator

Go
88
star
49

terraform-modules

Rancher Terraform Modules
HCL
85
star
50

os2

EXPERIMENTAL: A Rancher and Kubernetes optimized immutable Linux distribution based on openSUSE
Go
82
star
51

system-charts

Mustache
82
star
52

vagrant

Vagrant file to stand up a Local Rancher install with 3 nodes
Shell
79
star
53

rancher-dns

A simple DNS server that returns different answers depending on the IP address of the client making the request
Go
79
star
54

giddyup

Go
78
star
55

kontainer-engine

Provisioning kubernetes cluster at ease
Go
78
star
56

go-rancher

Go language bindings for Rancher API
Go
74
star
57

go-skel

Skeleton for Rancher Go Microservices
Shell
71
star
58

runc-cve

CVE patches for legacy runc packaged with Docker
Dockerfile
69
star
59

terraform-k3s-aws-cluster

HCL
67
star
60

agent

Shell
64
star
61

external-dns

Service updating external DNS with Rancher services records for Rancher 1.6
Go
63
star
62

terraform-provider-rancher2-archive

[Deprecated] Use https://github.com/terraform-providers/terraform-provider-rancher2
Go
62
star
63

kontainer-driver-metadata

This repository is to keep information of k8s versions and their dependencies like k8s components flags and system addons images.
Go
62
star
64

gitjob

Go
59
star
65

types

Rancher API types
Go
59
star
66

rancher.github.io

HTML
58
star
67

ui-driver-skel

Skeleton Rancher UI driver for custom docker-machine drivers
JavaScript
58
star
68

rancher-docs

Rancher Documentation
JavaScript
57
star
69

rke2-charts

Shell
56
star
70

os-services

RancherOS Service Compose Templates
Shell
54
star
71

client-python

A Python client for Rancher APIs
Python
49
star
72

hyperkube

Rancher hyperkube images
44
star
73

rancher-cloud-controller-manager

A kubernetes cloud-controller-manager for the rancher cloud
Go
44
star
74

steve

Kubernetes API Translator
Go
43
star
75

rodeo

Smarty
43
star
76

cis-operator

Go
43
star
77

rancherd

Bootstrap Rancher and k3s/rke2
Go
42
star
78

partner-charts

A catalog based on applications from independent software vendors (ISVs). Most of them are SUSE Partners.
Smarty
42
star
79

10acre-ranch

Build Rancher environment on GCE
Shell
41
star
80

secrets-bridge

Go
40
star
81

terraform-rancher-server

HCL
39
star
82

storage

Rancher specific storage plugins
Shell
39
star
83

k8s-sql

Storage backend for Kubernetes using Go database/sql
Go
37
star
84

lasso

Low level generic controller framework
Go
36
star
85

server-chart

[Deprecated] Helm chart for Rancher server
Shell
36
star
86

os-packer

Shell
36
star
87

pipeline-example-go

Go
36
star
88

cluster-template-examples

35
star
89

system-tools

This repo is for tools helping with various cleanup tasks for rancher projects. Example: rancher installation cleanup
Go
35
star
90

elemental-operator

The Elemental operator is responsible for managing the OS versions and maintaining a machine inventory to assist with edge or baremetal installations.
Go
33
star
91

image-mirror

Shell
31
star
92

rancher-metadata

A simple HTTP server that returns EC2-style metadata information that varies depending on the source IP address making the request.
Go
31
star
93

os-base

Base file system for RancherOS images
Shell
31
star
94

websocket-proxy

Go
29
star
95

rke-tools

Tools container for supporting functions in RKE
Go
29
star
96

gdapi-python

Python Binding to API spec
Python
28
star
97

wins

Windows containers connect to Windows host
Go
28
star
98

api-ui

Embedded UI for any service that implements the Rancher API spec
JavaScript
27
star
99

turtles

Rancher CAPI extension
Go
27
star
100

migration-tools

Go
27
star