How to Install Docker on Ubuntu 24.04
Let's walk through how to install Docker on Ubuntu 24.04. Before we start, it's good to know a few things to make sure everything goes smoothly.
First, make sure you're running Ubuntu 24.04. Docker works well with this version. Also, check if you're using a 64-bit system because Docker needs that to run properly (you probably are, 32 bit is rare these days).
If you've used Docker before or have older versions installed, you'll need to remove them to avoid any conflicts. You can do this by running the following command in your terminal:
sudo apt-get remove docker.io docker-compose docker-compose-v2 docker-doc podman-docker
This command will uninstall any old Docker packages that might cause issues with the new installation.
Now, let's move on to installing Docker. The best way to do this is by using Docker's official apt
repository. Here's how you do it:
- Set up Docker's
apt
repository:
Open your terminal and run these commands one by one:sudo apt-get update sudo apt-get install ca-certificates curl gnupg sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg echo \ "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] 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
These commands will set up the Docker repository so you can install and update Docker easily. - Install Docker:
Now that the repository is set up, you can install Docker with this command:sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
This will install the latest version of Docker Engine, along with other necessary components. - Verify the installation:
To make sure Docker is installed correctly, run this command:sudo docker run hello-world
This command will download a test image and run it in a container. If everything is set up right, you'll see a message confirming that Docker is working.
And that's it! You've installed Docker on Ubuntu 24.04. If you run into any issues, like needing to use sudo
to run Docker commands, you might want to check out Docker's post-installation steps to set up Docker for non-root users.
Remember, if you ever need to upgrade Docker, just follow the same steps to install it, but choose the new version you want to install.