Installing Docker Engine - lmmx/devnotes GitHub Wiki
Note: be prepared to restart your machine before starting this
The following guide is for me, on Linux Mint (Ubuntu base distro).
First remove old versions
for pkg in docker.io docker-compose docker-compose-v2 docker-doc podman-docker docker docker-engine containerd runc; do sudo apt-get remove $pkg; done
This did nothing, nothing to uninstall.
It’s OK if
apt-get
reports that none of these packages are installed.
...however this doesn't actually clarify whether this means the necessary uninstallation has taken
place or not (the fact that I still have a working docker
command strongly suggests it didn't).
If you still have docker installed
For better or worse I'm going to attempt to continue by assuming that all that was required was to uninstall the packages...
My version of docker is installed as a binary in /usr/bin
, and unfortunately I don't remember
exactly how I put it there...
I had more success following the advice on askubuntu here:
sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli
sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
That was all I needed to get rid of docker
on the command line. You can go further to remove
containers and images, but I didn't want that:
The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following commands:
sudo rm -rf /var/lib/docker /etc/docker sudo rm /etc/apparmor.d/docker sudo groupdel docker sudo rm -rf /var/run/docker.sock
Back to Docker Engine
So back to Docker Engine: I chose the recommended option of installing via repository.
NOTE This is for Linux Mint, so I am using
UBUNTU_CODENAME
instead ofVERSION_CODENAME
# 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 "$UBUNTU_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Then installed:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Note: in previous installations I have found an error with
docker-ce
that required restarting the machine, perhaps only if you have uninstalled and reinstalled rather than freshly installed
To test it, run sudo docker hello world
A quick check of docker images
showed my old container images were still there and visible to Docker.
The official docs say to run sudo docker run hello-world
and this likewise confirmed containers
could run.
(I restart at this point then come back to do post install)
Linux post-install
sudo groupadd docker # already exists
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
I did that but I still needed to run this to get it to work:
newgrp docker
- Problem: it turned out this was because newgrp docker "put me in" the group temporarily, it didn't persist in a new terminal!
- Solution: the
newgrp docker
apparently needed another restart to be applied.
I could then successfully run:
docker run hello-world