Docker is an open-source containerization platform that allows you to package, distribute, and run applications in isolated environments called containers.

Containers are isolated from each other and bundle the application code along with its dependencies, libraries, and configuration files. Unlike virtual machines, containers share the host operating system’s kernel, making them significantly more lightweight and faster to start.

Deploy an application with Docker using Docker Image

To deploy an application with Docker, you must first have an image available.

The image, or Docker image, is a read-only artifact that contains a set of instructions for creating a container that can run on the Docker platform. The image provides a particularly convenient method for creating preconfigured application packages and server environments.

The Docker image can be created using a Dockerfile and with the docker build command:

$ docker build .

[+] Building 4.2s (5/5) FINISHED

 => [internal] load build definition from Dockerfile

 => [internal] load metadata for docker.io/library/busybox:latest

 => [1/2] FROM docker.io/library/busybox:latest

 => [2/2] RUN ls -lh /

 => exporting to image

 => => writing image sha256:f52f38b7823e

We can find the newly created image in the image list with the docker image ls command.

To deploy the application, you will need to have an Ubuntu Server instance with Docker installed. This instance can be on a local or remote virtual machine, or it can be on a dedicated physical machine.

Note that the virtual machine where the deployment will be performed must have access to the created image. To do this, you must copy the image to a Docker registry accessible via the internet. There are many services available for this, including Docker Hub, Amazon ECR, GitHub Container Registry (ghcr.io), and Google Artifact Registry (which replaced the now-retired Google Container Registry).

Furthermore, we will need to create an account to get the registry URL and enable it to upload Docker images. At this point, you can load the image using the docker push command:

$ docker image push registry-host:5000/myadmin/rhel-httpd:latest

Once this has been done, we access the Ubuntu Docker machine to get the image from the registry:

$ docker pull registry-host:5000/myadmin/rhel-httpd:latest

sha256:45b23dee08...c5cb2: Pulling from myadmin/rhel-httpd

5a132a7e7af1: Already exists

fd2731e4c50c: Already exists

28a2f68d1120: Already exists

a3ed95caeb02: Already exists

Digest: sha256:45b23dee08...c5cb2

Status: Downloaded newer image for registry-host:5000/myadmin/rhel-httpd:latest

As soon as we have the image, we can launch a container with the docker run command:

$ docker run -p 80:80 registry-host:5000/myadmin/rhel-httpd:latest

Running commands from the container

The -p attribute enables you to map port 80 to make it accessible from the outside. Now, you should be able to run the docker ps command, and you should see the newly launched container in the list.

To execute commands from the container that is running, you can run the docker exec command. By running the bash or sh command, you may use the shell inside the container as follows:

$ docker exec -it <container_name> bash

Managing multi-container applications with Docker Compose

If your application requires multiple containers working together – for example, a web server and a database – you don’t necessarily need a full orchestration platform. Docker Compose provides a simple and effective way to define and manage multi-container setups using a single YAML configuration file.

Docker Compose is ideal for development environments, testing, and small-scale production deployments. To learn more, read our guide on Docker Compose.

Scaling multiple containers dynamically: container orchestration tools

What if we want to scale the number of containers dynamically across multiple hosts? For this, we need a container orchestration tool.

The industry standard is Kubernetes, which has become the dominant container orchestration platform. Other options include Amazon ECS and Docker Swarm, though Swarm’s development has slowed significantly in favor of Kubernetes-based solutions.

To understand the differences between these approaches, read our article on Docker vs Kubernetes.

From Dockerfile to deployment

We hope that this guide has given you a clear understanding of how to build a Docker image and deploy a container. Docker is an essential tool for anyone managing server infrastructure, enabling faster and more consistent application deployments across environments.

If you manage Docker containers in production, remember that a solid backup strategy is just as important as the deployment itself. Uranium Backup supports backup of virtual machines, databases, and the data that powers your containerized applications.

Read related articles