Docker on Ubuntu 24.04

How to Install Docker on Ubuntu 24.04

Docker is a platform designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all parts it needs, such as libraries and other dependencies, and ship it all out as one package. This ensures that the application runs reliably when moved from one computing environment to another.

Docker provides tools and a platform to manage these containers efficiently, allowing developers to focus on writing code without worrying about the environment in which their code will run.

In this tutorial, we will show you how to install Docker on Ubuntu 24.04 OS.

Step 1: Update Operating System

Update your Ubuntu 24.04 operating system to make sure all existing packages are up to date:

# apt update && apt upgrade

Step 2: Install Dependencies

Install the required packages to allow Ubuntu 24.04 to access the Docker repositories over HTTPS:

# apt install apt-transport-https ca-certificates curl software-properties-common

Step3: Add GPG Key

Add the Docker repository GPG key with the following command:

# curl -fsSL | sudo apt-key add -

Step 4: Add Docker Repository

To be able to install Docker on Ubuntu 24.04 you need to add the Docker repository to APT sources:

# add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

Step 5: Install Docker

Once the repository has been added to the system, you are now ready to install Docker with the following command:

# apt install docker-ce

You can verify the installed version of Docker with the following command:

# docker --version


Docker version 26.0.0, build 2ae903e

Check the status of the service:

# systemctl status docker

Example output:

● docker.service - Docker Application Container Engine
     Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
     Active: active (running)
TriggeredBy: ● docker.socket
   Main PID: 7047 (dockerd)
      Tasks: 7
     Memory: 27.4M (peak: 27.9M)
        CPU: 396ms
     CGroup: /system.slice/docker.service
             └─7047 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

By default, Docker should start on boot. But if it doesn’t, you can enable it to start automatically at the next boot with the following command:

#systemctl enable docker

Step 6: Test Docker

Run a test Docker container to ensure everything is working correctly:

# docker run hello-world

This command downloads a test image from the Docker Hub repository and runs it in a container:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6
Status: Downloaded newer image for hello-world:latest

Step 7: Using the Docker Command

To see only the active containers, run:

# docker ps

To list all containers, including the inactive ones, add the -a flag:

# docker ps -a

Start a stopped container the syntax is:

# docker start [container-ID | container-name]

Stop a running container the syntax is:

# docker stop [container-ID | container-name]

Remove an unnecessary container the syntax is:

# docker rm [container-ID | container-name]

To view all of the available subcommands use the following command:

# docker


  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

Step 8: Run Docker without Sudo

If we want to use Docker without root privileges, you need to run the following command:

# usermod -aG docker $User

Note: “$USER” is just a place holder that needs to be replaced with your username.

After that, restart the system, and the changes will be applied.

Comments and Conclusion

Congratulations! You have successfully installed Docker on your Ubuntu 24.04 OS.

Also, you can check our tutorial how to install Portainer on Ubuntu OS. Portainer is a container management tool that provides a web-based graphical user interface (GUI) for managing Docker containers, images, networks, and volumes.

For additional help or useful information, we recommend you to check the official Docker documentation.

If you have any questions please leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *