A quick, TL;DR copy/paste for installing Docker on Ubuntu 22.04.
Synthesized from Docker: Install Using the Convenience Script.
-
Figure out which version of Ubuntu (or other Linux) you’re runnin'
cat /etc/issue
Ubuntu 22.04 LTS \n \l
-
Install a few prerequisites
sudo apt update sudo sh -eux <<EOF # Install newuidmap & newgidmap binaries apt-get install -y uidmap EOF
-
Use Docker’s own script to get started
curl -fsSL https://get.docker.com -o get-docker.sh bash get-docker.sh dockerd-rootless-setuptool.sh install
-
Set the appropriate ENVs
DO NOT follow the ON-SCREEN instructions!# You should use quotes when setting `DOCKER_HOST`. # # Ex: export DOCKER_HOST='unix:///run/user/1000/docker.sock' DETECTED_USER_ID="$(id -u)" echo "export DOCKER_HOST='unix:///run/user/$DETECTED_USER_ID/docker.sock'" | tee -a ~/.bashrc
# You probably DON'T need to change your PATH at all. # If you do, use quotes and put the system PATH at the end # # Ex: export PATH="$PATH:/usr/bin/" echo 'export PATH="$PATH:/usr/bin/"' | tee -a ~/.bashrc
Troubleshooting
Why don’t export
s from dockerd-rootless-setuptool.sh
don’t work (or break things that did work)?
- The
export
s are missing necessary quotes. If you have any spaces or special characters in yourPATH
, such as in your username, thePATH
will be broken. - Rather than checking the PATH resolution of
docker
, it always gives you a (usually) unnecessaryPATH
export that will place/usr/bin
as the firstPATH
entry, which will cause locally installed programs (webi
,brew
,~/bin
,~/.local
)