Skip to content

Instantly share code, notes, and snippets.

@jkislin
Last active January 22, 2025 16:32
Show Gist options
  • Select an option

  • Save jkislin/a575780249c3580a472e25c07d3fd68f to your computer and use it in GitHub Desktop.

Select an option

Save jkislin/a575780249c3580a472e25c07d3fd68f to your computer and use it in GitHub Desktop.
docker_setup.sh
# Jon Kislin's end to end Linux docker install guide, adapted from:
# https://docs.docker.com/engine/install/ubuntu/
# https://docs.docker.com/engine/install/linux-postinstall/
# Uninstall docker on WSL
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# Actually install the dang thing and its dependencies
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# add the docker group to linux (if you already did this, doesn't hurt to run the command again, so do it anyway
sudo groupadd docker
# get yourself added (again, doesn't matter if you run twice)
sudo usermod -aG docker $USER
# register the changes so (maybe) you don't have to restart WSL
newgrp docker
# iptables legacy for ubuntu 22.04
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo dockerd &
# try the docker hello world
docker run hello-world
# systemd enablement (will start docker everytime so you don't have to)
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment