Last active
December 6, 2022 17:32
-
-
Save rwcitek/81a942d9b7e35d104e16d1591f93018a to your computer and use it in GitHub Desktop.
Docker out of Docker using Ubuntu 22.04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted from: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04 | |
## This allows a Docker container to connect to the Docker server on the host to manage Docker resources | |
# run a Docker instance in the background | |
docker container run \ | |
--rm \ | |
-v /var/run/docker.sock:/var/run/docker.sock \ | |
--name dood \ | |
ubuntu:22.04 sleep inf & | |
# Setup environment for Docker out of Docker (DooD) | |
<<'eof' docker container exec -i dood /bin/bash | |
export DEBIAN_FRONTEND=noninteractive | |
apt-get update | |
apt-get install -y apt-transport-https ca-certificates curl software-properties-common | |
curl -fsSL https://download.docker.com/linux/$( lsb_release -is | tr A-Z a-z )/gpg | | |
gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/$( lsb_release -is | tr A-Z a-z ) $(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list | |
apt-cache policy docker-ce | |
apt-get update | |
apt-get install -y docker-ce | |
eof | |
# Exec into the instance | |
docker container exec -it dood /bin/bash | |
# Can commit or otherwise save instance | |
# ... { insert commands here } | |
# Remove the instance | |
docker container stop dood |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment