As someone that’s created a lot of Docker instances on Linux, the method is now second nature to me. But at one time I had no idea on the best way to setup Docker on Ubuntu Linux.
I tried a ton of methods and tutorials, with all of them missing something. This often lead to installs not working quite right or being hard to scale.
I wanted to share with you my method for installing Docker on Ubuntu Linux. I’ve also written this on Medium in case you prefer reading over there.
How to setup MySQL Replication using SSL on Ubuntu
Let’s setup MySQL replication using SSL on Ubuntu. We’ll be using Ubuntu 22.04 LTS and…
Protected: Liminal: Why Should Small Businesses Blog in 2025?
TL;DR small businesses should blog as it shows greater activity on your website, can aid…
How to Make a WordPress Plugin in 2025
To make a WordPress plugin in 2025 requires only 3 files, the plugin PHP file,…
How to Move MySQL Database on Windows
Recently, I’ve had to move MySQL database on Windows to another drive. This was the…
Do I Have to Pay for Windows? – 6 Alternatives
I think we’ve all thought ‘Do I Have to Pay for Windows?’ when planning out…
How To Screenshot On All 3 Desktop OS’s
Knowing how to screenshot is one of the corner stones to receiving or providing technical…
Introduction
So as an overview, I will be using Ubuntu 22.04 but you can use the latest 24.04 if you like. The general flow of this setup will be to update Linux and create the directories that are needed. Once that’s done, we can set the permissions and start adding docker to our apt-get repository.
Lets jump in now!
The Best Way To Setup Docker On Ubuntu Linux
First things first, is to update your Ubuntu machine. You could skip this step is are sticking to a particular release, but I always take the opportunity out of best practice.
Update Ubuntu
To update Ubuntu, run the below commands:
sudo do-release-upgrade
sudo apt-get update; sudo apt-get upgrade
You might also be prompted on either of those commands, just press ‘Y’ and then click enter.
Creating Directories
We now need to create the directories needed for Docker. Follow the commands below to complete this:
note that a new directory will need to be created for every image you want to run in Docker
sudo mkdir -p /home/docker
sudo mkdir -p /home/docker/image (e.g. traefik)
Install Docker
Now onto the meat and potatoes! Run the following commands to install Docker:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
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
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
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
I know that’s quite a lot just to install Docker, but this does a bunch of helpful stuff too. For one, it adds Docker into the apt repository, which enabled apt to install the latest stable version of Docker.
Verify Docker Install
Finally, now that you’ve installed Docker using the commands above we can check it’s working.
Thankfully, Docker includes a simple way to do this. Use the command below:
sudo docker run hello-world
And as long as you get an output similar to the below screenshot, you’re all good!

Thanks for following along, I hope this was helpful!
Enjoy! 🎉