Share your love
Set up Docker CE For Ubuntu 24.04 – Easy and Full Setup
This guide intends to show you how you can set up Docker CE For Ubuntu 24.04. As you must know, Docker is an open-source tool that you can use to create containers. Docker CE is a package that is provided by Docker. The package is available through a third-party package repository provided for most Linux distributions. It is available for free.
You can now follow the guide steps from the Orcacore team and start your Docker CE installation on Ubuntu 24.04.
Table of Contents
Step-by-Step Set up Docker CE For Ubuntu 24.04
To start the installation of Docker CE for Ubuntu 24.04, you must access your Ubuntu system as a non-root user with sudo privileges. If you want to know how to create a sudo user, you can check this guide on Create a New Sudo User on Ubuntu 24.04.
Step 1 – Install Required Packages For Docker Setup on Ubuntu 24.04
To set up Docker CE for Ubuntu 24.04, you need to prepare your system first. Run the system update and upgrade with the following command:
sudo apt update && sudo apt upgrade -y
Then, you need some required packages and dependencies. To install them, run the following command:
sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y
Now proceed to the next step to install Docker CE on Ubuntu 24.04. In this guide, we use the official Docker APT repository to set up Docker CE for Ubuntu 24.04.
Step 2 – Add Docker’s official GPG key on Ubuntu 24.04
At this point, you must add the official GPG key of the Docker APT repository on your Ubuntu 24.04. To do this, you can run the following commands:
# 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
Step 3 – Add Docker repository to the APT sources on Ubuntu 24.04
Now you must add the repository to APT sources. To do this, you can easily run the following command:
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
Once you are done, run the system update to apply the changes:
sudo apt update
Step 4 – Install Docker on Ubuntu 24.04
When you are finished with adding the repository, you can install and set up Docker CE For Ubuntu 24.04 by using the following command:
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin -y
Check Docker Status
Your Docker CE service must be enabled and activated during the installation of Docker CE For Ubuntu 24.04. To verify it, you can run the command below:
sudo systemctl status docker
In your output, you should see:
Step 5 – Execute Docker Commands Without Using Sudo
At this point, you have set up Docker CE for Ubuntu 24.04. As you may know, the docker command can only be run by the root user or the user in the docker group. A Docker group is created in the installation process by default.
If you don’t want to use sudo for the docker command you need to add your user to the docker group with the following command:
sudo usermod -aG docker ${USER}
To apply this change, run the following command:
su - ${USER}
Here you will be asked to enter your username’s password to continue.
You can verify that your user added to the docker group with the following command:
id -nG
In the rest of the article on Docker CE For Ubuntu 24.04, we run the docker commands as a user in the docker group. If you don’t want this remember to run commands with a user with sudo privileges.
Now let’s see how the docker command works.
Step 6 – How To Use Docker on Ubuntu 24.04?
First, let’s start with the general syntax of the Docker command:
docker [option] [command] [arguments]
Then, you can list all available subcommands for Docker with the command below:
docker
In your output, you should see:
Now proceed to the following steps to see how to work with Docker commands, such as pulling images, creating containers, etc.
Work with Docker Images on Ubuntu 24.04
The Docker Image is a portable file that contains a set of instructions that specify which software components the Container should run and how to run it. By default, Docker pulls these images from Docker Hub.
First, you can check that you have access and download images from Docker Hub with the following command:
docker run hello-world
In your output, you should see:
Then, you can start to search and download Docker images on Ubuntu 24.04. For example, we search for an Ubuntu image with the command below:
docker search ubuntu
In your output, you will see something similar to this:
After searching, we want to download the official Ubuntu image by using the command below:
docker pull ubuntu
Once the download is completed, you should see:
Also, you can list your downloaded images by using the following Docker command:
docker images
Exmaple Output
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest edbfe74c41f8 6 weeks ago 78.1MB
hello-world latest d2c94e258dcb 16 months ago 13.3kB
At this step of setting up Docker CE for Ubuntu 24.04, you have learned to work with Docker images. Let’s see how you can run Docker containers and work with them.
Work with Docker Containers on Ubuntu 24.04
Containers can be the best replacement for virtual machines. Containers separate the executive environments and share the operation system’s core.
For example, run the container using the latest image of Ubuntu we have downloaded. To do this run the following command:
docker run -it ubuntu
Note: -it switches and gives you interactive shell access into the container.
You should see this form in your output:
orca@983f76ee9ca6:/#
Important note: Remember the container ID. Here the container ID is 983f76ee9ca6.
Now you can run any command in your container without sudo because you execute commands in the container as a root user. For example, we run the apt update and install the Nginx web server in our Ubuntu container:
orca@983f76ee9ca6:/# apt update
orca@983f76ee9ca6:/# apt install nginx -y
You can verify your installation by checking its version from the container:
orca@983f76ee9ca6:/# nginx -v
nginx version: nginx/1.24.0 (Ubuntu)
Note: Any changes you make inside the container only apply to that container.
To exit the container type exit:
orca@983f76ee9ca6:/# exit
List Available Containers
Also, you can view active containers by running the following command:
docker ps
Example Output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Note: We have started two containers in this article. But they are not activated. So they are not shown in active containers.
To see all containers both active and inactive run the following command:
docker ps -a
Example Output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
983f76ee9ca6 ubuntu "/bin/bash" 9 minutes ago Exited (130) 4 minutes ago brave_taussig
957b983291e2 hello-world "/hello" 20 minutes ago Exited (0) 20 minutes ago nervous_maxwell
Also, you can see the latest container that you have created with the following command:
docker ps -l
Example Output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
983f76ee9ca6 ubuntu "/bin/bash" 10 minutes ago Exited (130) 5 minutes ago brave_tausig
Manage Docker Containers
You can start and stop a container with the container ID or the container’s name. Here we start the Ubuntu container with its ID:
docker start 983f76ee9ca6
Now you can check the status to see if your container is active:
docker ps
Here you can stop the container. Now we use the container’s name to stop it. The name of the container will given to you by listing them.
docker stop brave_tausig
Also, you can remove a container with the container ID or the container’s name. For example, remove the hello-world container with its name by the following command:
docker rm nervous_maxwell
That’s it. You are done with Setting up Docker CE for Ubuntu 24.04. For more information, you can visit the official Docker Documentation page.
Conclusion
As you saw from the guide steps, the installation of Docker on Ubuntu is straightforward. You can easily add the official Docker repository to APT sources and install Docker CE. Also, working with Docker commands is simple. You can easily search and download Docker images, and run and manage Docker containers. Hope you enjoy this guide on Setting up Docker CE for Ubuntu 24.04.
You may also like to read the following articles:
Run Docker Containers with Portainer
Start a Docker Container with Exited Status
Run a Python Script in a Linux Docker Container
Heimdall Application Dashboard on Linux with Docker
Install Docker CE on Debian 12 Bookworm
FAQs
Can Docker CE Run on Other Versions of Ubuntu?
Yes, Docker CE can run on Ubuntu 18.04, 20.04, and Ubuntu 22.04. Each version might have slight differences in installation procedures or dependencies.
How Do I Update Docker CE on Ubuntu 24.04?
To update Docker CE, use the following command:sudo apt update && sudo apt upgrade
Can I Use Docker Without Sudo?
Yes, you can configure Docker to run without sudo. Add your user to the Docker group as we explained in the guide steps.
Is Docker CE Free to Use?
Yes, Docker CE is open-source and free to use. However, Docker offers a paid version called Docker Enterprise for additional features and support.