Tag Archives: Docker

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 https://download.docker.com/linux/ubuntu/gpg | 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] https://download.docker.com/linux/ubuntu $(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

Output:

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
       Docs: https://docs.docker.com
   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

Output:

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

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.

How to Install Portainer on Ubuntu 22.04

Portainer is an open-source container management tool that provides a web-based graphical user interface (GUI) for managing Docker containers, images, networks, and volumes.

Portainer supports multiple Docker environments, including Docker Swarm, Kubernetes, and Docker Desktop. It also provides features such as user authentication, role-based access control (RBAC), and multi-tenancy, making it a suitable tool for managing Docker resources in production environments.

In this tutorial, we will show you how to install Portainer on Ubuntu 22.04 OS.

Step 1: Update Operating System

Before we start, it is always a good practice to update your Ubuntu system to the latest packages. Open the terminal and run the following commands:

# apt-get update && sudo apt-get upgrade

Step 2: Install Docker

Portainer is a Docker management tool, so you need to have Docker installed on your Ubuntu system. If you don’t have Docker installed, you can install it by running the following commands:

# apt-get install docker.io

You can start the Docker service and configure it to run on startup by entering the following commands:

# systemctl start docker
# systemctl enable docker

Verify the status of the docker service using systemctl status command:

# systemctl status docker

Output:

 docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running)
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 2449 (dockerd)
      Tasks: 7
     Memory: 22.7M
        CPU: 315ms
     CGroup: /system.slice/docker.service
             └─2449 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Step 3: Install Portainer

Once you have Docker installed on your system, you can proceed to install Portainer.

Run the following command to pull the Portainer image from Docker Hub:

# docker pull portainer/portainer-ce:latest

Then, start the Portainer container by running the following command:

# docker run -d -p 9000:9000 --restart always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer-ce:latest

The above command will start a Portainer container in the background and bind it to the port 9000.

Step 4: Access Portainer Web Interface

You can now access the Portainer web interface by opening a web browser and visiting http://your-IP-address:9000.

You should get Portainer login page to create an admin password. Set your admin user and password and click on the Create user button.

You will be asked to select the Docker environment that you want to manage. Select “Proceed using the local environment which Portainer is running in”

You should see the following page:

Step 5: Deploy Container Using Portainer

Now you can test your Portainer setup by deploying a test Docker container. Follow the steps below to install an Nginx web server.

Select Containers in the menu on the left side:

Click the Add container button in the action bar.

Type information for the container you want to run, including the container name, the image name, and the connection ports. Then select the Deploy the container button.

After completing the above steps, to verify the creation of the defined container, one can check on the dashboard.

Open your browser and type http://your-IP-address:8080 . You will see the Nginx webserver welcome page.

Comments and Conclusion

Congratulations! You have successfully installed Portainer to manage Docker containers on Ubuntu 22.04.

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