In this guide, we shall see How to Install Docker CE on Ubuntu 24.04. A platform called Docker was created to simplify the process of developing, deploying, and operating applications that use containers. With containers, an application developer may bundle all the required components, like libraries and other dependencies, and send them as a single package. This guarantees that the program functions dependably when it is transferred between different computer environments.
Developers can concentrate on building code rather than wondering about the environment in which it will operate because Docker offers the tools and a platform to manage these containers effectively.
How to Install Docker CE on Ubuntu 24.04
Let’s get started!
Step 1. Update the System
Run the following command to update your system packages and reboot after an update.
sudo apt update && apt upgrade -y
sudo reboot
Step 2. Install Required Dependencies
To enable Ubuntu 24.04 to connect to the Docker repositories over HTTPS, install the following packages:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add GPG Key
Use the following command to add the GPG Key for Docker on Ubuntu 24.04.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add Docker Repository
Once you add the GPG Key, you must add the Docker Repository. Execute the following command.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
Step 3. Install Docker On Ubuntu 24.04
You are now ready to install Docker by simply running the below command.
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
Add your local user to the docker group after installing docker and its dependencies so that the local user can use it without using sudo to perform the docker command.
$ sudo usermod -aG docker $USER
$ newgrep docker
$ docker --version
Now start and enable docker services.
sudo systemctl enable docker
sudo systemctl start docker
Verify the docker status.
$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Tue 2024-05-21 19:30:38 EAT; 12min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 4411 (dockerd)
Tasks: 9
Memory: 28.8M (peak: 30.1M)
CPU: 1.103s
CGroup: /system.slice/docker.service
└─4411 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
As you can see above Docker is running.
Test Docker
We can now run the hello-world below to test the installation of Docker if it’s working fine.
$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:266b191e926f65542fa8daaec01a192c4d292bff79426f47300a046e1bc576fd
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
The above output shows that docker is working well.
Step 4. Using the Docker Command
- If you want to check the active containers simply run;
docker ps
- You can add the -a flag to list all containers, even those that are not in use:
docker start <container-ID | container-name>
- To stop running the container.
docker stop <container-ID | container-name>
- To remove container use:
docker rm <container-ID | container-name>
For more options run the help command.
$ docker --help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Common Commands:
run Create and run a new container from an image
exec Execute a command in a running container
ps List containers
build Build an image from a Dockerfile
pull Download an image from a registry
push Upload an image to a registry
images List images
login Log in to a registry
logout Log out from a registry
search Search Docker Hub for images
version Show the Docker version information
info Display system-wide information
Management Commands:
builder Manage builds
buildx* Docker Buildx
checkpoint Manage checkpoints
compose* Docker Compose
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
plugin Manage plugins
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Swarm Commands:
config Manage Swarm configs
node Manage Swarm nodes
secret Manage Swarm secrets
service Manage Swarm services
stack Manage Swarm stacks
swarm Manage Swarm
Commands:
attach Attach local standard input, output, and error streams to a running container
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
export Export a container's filesystem as a tar archive
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
wait Block until one or more containers stop, then print their exit codes
Global Options:
--config string Location of client config files (default "/home/cbett/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and
default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket to connect to
-l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/home/cbett/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/home/cbett/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/home/cbett/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Run 'docker COMMAND --help' for more information on a command.
For more help on how to use Docker, head to https://docs.docker.com/go/guides/
Conclusion
That it! We have successfully reached the end of our guide on How to Install Docker CE on Ubuntu 24.04. As you have seen the installation of Docker CE on Ubuntu involves a few steps. Hope you found this guide useful.
Read more about Docker here.
Other guides on our platform: