What is Docker?
Docker is a platform that allows applications to be packaged and run in isolated environments called containers together with the code, libraries, runtime, and other dependencies they need. In simple terms, moving only the application code to another computer is not always enough. An application may require a specific version of Python, Java, or Node.js, particular libraries, system settings, and other dependencies. Because of this, an application may work on one computer but fail to run on another. Docker helps reduce this problem by packaging the application together with much of the environment required to run it. For example, for a Spring Boot application, the Java runtime, the application's .jar file, and the required configuration can be included in a Docker image. A container created from that image can then run in a similar way on different systems that support Docker. Docker is widely used especially in Backend Development, Microservices, DevOps, CI/CD, testing, and deployment processes.
What Is Docker Used For?
One of Docker's main purposes is to help applications run more consistently across development, testing, and production environments.
For example, a developer's computer may have:
- Java 21;
- PostgreSQL;
- Redis;
- specific libraries.
Another developer's computer may have different versions of these tools.
This often leads to the familiar problem:
“Works on my machine, but not on the server.” Docker allows much of the environment required by the application to be defined inside an image.
With Docker, you can:
- containerize applications;
- isolate dependencies of different projects;
- standardize the development environment across a team;
- quickly start databases and other services;
- run microservices in separate containers;
- create testing environments;
- build and deploy applications in CI/CD processes.
What Is a Container?
A Container is an isolated running process created from a Docker image.
A simple comparison:
Docker Image → Template
Docker Container → Running instance created from that template
For example, several separate containers can be created from the same nginx image.
docker run nginx
If the required image does not already exist locally, this command can download it and start a container based on that image. A container can have its own filesystem view, processes, and network environment. However, unlike a Virtual Machine, it does not run a completely separate operating system kernel. This makes containers relatively lightweight and fast to start.
What Is a Docker Image?
A Docker Image is an immutable package used to create containers.
An image may include:
- application code;
- runtime;
- libraries;
- dependencies;
- system files;
- startup command.
For example, an image for a Python application may contain:
Linux base files
↓
Python runtime
↓
Python dependencies
↓
Application code
↓
Startup command
Once an image is created, it is not modified directly. If changes are required, a new image is built.
What Is the Difference Between a Docker Image and a Container?
Images and Containers are often confused. An Image is a ready-made package containing the files and configuration required for an application to run. A Container is a running instance of that image.
A simple analogy:
Image → application template
Container → running version of that template
Multiple containers can be created from the same image.
For example:
nginx image
↓
Container 1
nginx image
↓
Container 2
nginx image
↓
Container 3
Even though these containers are created from the same image, they can run as separate processes.
What Is a Dockerfile?
A Dockerfile is a file containing instructions that define how a Docker image should be built.
For example, for a simple Java application:
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY application.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
Here:
FROM — defines which base image to start from;
WORKDIR — defines the working directory inside the container;
COPY — copies a file into the image;
EXPOSE — documents which port the application uses;
ENTRYPOINT — defines which command should run when the container starts.
A Dockerfile is not a container itself. It is a recipe used to build an image.
What Is docker build?
docker build is used to create an image based on a Dockerfile.
For example:
docker build -t my-app:1.0 .
Here:
my-app — image name;
1.0 — tag;
. — build context.
After the build is completed, a container can be created from the resulting image.
What Is docker run?
docker run is used to create and start a new container based on an image.
For example:
docker run my-app:1.0
To start the container in the background:
docker run -d my-app:1.0
can be used.
-d means detached mode and allows the container to run in the background without blocking the terminal.
What Is docker ps?
To see currently running containers:
docker ps
is used.
To see all containers, including stopped ones:
docker ps -a
can be used.
These are among the most commonly used basic Docker commands.
What Is Docker Port Mapping?
Port mapping can be used to make an application running inside a container accessible from the host computer.
For example:
docker run -p 8080:80 nginx
Here:
8080 — host port;
80 — container port.
In this case, when the user accesses:
localhost:8080
on the host computer, the traffic is forwarded to port 80 of the container. Port mapping is especially important when working with web servers, REST APIs, and database containers.
What Is a Docker Volume?
Data written inside a container may be lost when the container is deleted. For example, if you create a PostgreSQL database container and store all data only in the container's writable layer, deleting the container may also delete that data. Docker Volumes are used to store persistent data.
A simple structure:
Container
↓
Docker Volume
↓
Persistent Data
A Volume is managed separately from the lifecycle of the container.
For example:
docker volume create postgres-data
can be used to create a volume.
Volumes can be used for:
- databases;
- uploaded files;
- other persistent data.
What Is a Bind Mount?
A Bind Mount allows a specific file or directory on the host computer to be used inside a container. For example, during development, you can mount a source code directory into a container.
Volumes are managed by Docker. Bind Mounts work with a specific existing path on the host system. These two mechanisms may be used for different purposes.
What Is a Docker Network?
Docker uses networks to allow containers to communicate with each other.
For example:
Backend Container
↓
Docker Network
↓
PostgreSQL Container
The Backend container can connect to the database container through the same Docker network. This approach is especially important in multi-container applications. Docker provides different network drivers. One of the most common approaches in local projects is the bridge network.
What Is Docker Compose?
Docker Compose is a Docker tool that allows applications consisting of multiple containers to be managed through a single configuration file.
For example, a Backend project may include:
- Spring Boot application;
- PostgreSQL;
- Redis.
Each of these can be started using separate docker run commands. With Docker Compose, all services can instead be defined in a compose.yaml file.
For example:
services:
app:
build: .
ports:
- "8080:8080"
db:
image: postgres:17
environment:
POSTGRES_DB: app
POSTGRES_PASSWORD: password
Then:
docker compose up
can be used to start all services together. Docker Compose is especially useful in development environments and when managing applications made up of multiple services.
What Is the Difference Between Dockerfile and Docker Compose?
Dockerfile and Docker Compose do not serve the same purpose. A Dockerfile defines how an image should be built. A Compose file defines how one or more containers should run.
A simple comparison:
Dockerfile
↓
Docker Image
↓
Container
and:
compose.yaml
↓
App Container
Database Container
Redis Container
...
In real projects, Dockerfile and Docker Compose can be used together.
What Is Docker Engine?
Docker Engine is the core Docker technology used to create and run containers. Docker Engine uses a client-server architecture.
Its main components include:
- Docker daemon;
- Docker API;
- Docker CLI.
When a user runs a command such as:
docker run nginx
the Docker CLI communicates with Docker Engine and requests the appropriate operation.
What Is Docker Daemon?
Docker daemon — dockerd — is one of the main background processes of Docker Engine.
The daemon participates in managing Docker objects such as:
- images;
- containers;
- networks;
- volumes.
On Unix and Linux systems, background processes that run without direct user interaction are commonly called daemons. For more information about this concept, you can visit JET Academy's “What Is a Daemon?” glossary page.
What Is Docker Hub?
Docker Hub is a container registry service used to store and share Docker images.
For example:
docker pull postgres
can be used to download the PostgreSQL image from a registry. To upload an image to a registry, docker push is used.
Docker Hub contains:
- Docker Official Images;
- images from different vendors;
- community images.
In production projects, it is important to pay attention to the source, update history, and security of an image before using it.
What Is a Docker Registry?
A Registry is a server or service where Docker images are stored.
Docker Hub is one example of a registry.
Other examples include:
- GitHub Container Registry;
- Amazon ECR;
- Azure Container Registry;
- Google Artifact Registry.
Registries may contain repositories, and those repositories may contain images with different tags.
What Is the Difference Between Docker and a Virtual Machine?
Docker containers and Virtual Machines both provide isolation, but they work differently. A Virtual Machine usually runs with its own complete operating system and kernel. A Container is an isolated process that uses the host system's kernel.
A simplified comparison:
Virtual Machine
Hardware
↓
Host OS
↓
Hypervisor
↓
Guest OS
↓
Application
Container
Hardware
↓
Host OS
↓
Container Runtime
↓
Container
↓
Application
Containers are generally lighter and start faster than Virtual Machines. However, this does not mean containers and Virtual Machines replace each other in every situation. Running Docker containers on top of Virtual Machines is a common approach in real-world infrastructure.
What Is the Difference Between Docker and Kubernetes?
Docker is mainly associated with:
- creating container images;
- running containers;
- local container workflows.
Kubernetes is a platform used for orchestrating and managing large numbers of containerized applications at scale.
A simple comparison:
Docker → create and run containers. Kubernetes → manage and scale multiple container workloads.
Kubernetes provides features such as:
- deployment;
- scaling;
- service discovery;
- self-healing.
After learning Docker, you can move on to Kubernetes to learn container orchestration.
How Is Docker Used in Microservices?
In Microservices Architecture, an application is divided into smaller and independent services.
For example, an e-commerce system may consist of:
User Service
Product Service
Order Service
Payment Service
Each service can be built as a separate Docker image and run in a separate container.
This can make it easier to:
- deploy services separately;
- run different versions;
- scale services independently;
- isolate their dependencies.
JET Academy's Java Backend program also teaches Microservices and Docker Compose together within the same module through practical exercises.
How Is Docker Used with Spring Boot?
A Spring Boot application can first be built as a .jar file. Then, a Dockerfile can be used to create an image for the application.
A simple process:
Spring Boot
↓
JAR
↓
Dockerfile
↓
Docker Image
↓
Container
When the container starts, the Spring Boot application runs inside Docker. PostgreSQL can also run in a separate container, and the two services can communicate through a Docker network. This approach is widely used especially in Backend Development and Microservices projects.
How Is Docker Used in Python Projects?
Python Backend applications can also be containerized with Docker.
For example, in a Django project:
Django Application
↓
Docker Image
↓
Application Container
and separately:
PostgreSQL Container
Redis Container
Celery Worker Container
can be created.
Docker Compose can help manage all of these services together. For this reason, Docker is also an important deployment and development tool in Python Backend programming.
How Is Docker Used in CI/CD?
In a CI/CD process, an automated pipeline may start after application code is pushed to a repository.
For example:
Git Push
↓
Tests
↓
Docker Image Build
↓
Image Registry
↓
Deployment
The pipeline can:
- build the Docker image;
- test it;
- push it to a registry;
- deploy it to a server.
Docker's image-based approach helps create a more consistent deployment process between development and production environments.
How Can You View Logs Inside a Docker Container?
When a problem occurs in a container, logs are one of the first places to check.
For example:
docker logs container-name
can be used to view the container logs.
To follow logs in real time:
docker logs -f container-name
can be used.
In addition:
docker inspect container-name
shows configuration and runtime information about the container. Systematically identifying problems is part of the Debugging process in programming.
What Is docker exec?
docker exec can be used to run a command inside a running container.
For example:
docker exec -it container-name sh
may open a shell inside the container. This can be useful during development and troubleshooting for inspecting files and processes inside the container. In production systems, however, it is generally better to fix the image or deployment configuration instead of manually changing things directly inside a running container.
Are Docker Containers Secure?
Containers provide a certain level of isolation, but using Docker does not automatically make an application completely secure.
For better security, it is important to:
- use trusted base images;
- update images regularly;
- avoid adding unnecessary packages to images;
- avoid storing secrets and passwords inside images;
- avoid running containers with unnecessary root privileges;
- expose only the ports that are required;
- use image vulnerability scanning.
Container security is a broad topic and requires special attention in production systems.
What Are the Advantages of Using Docker?
One of Docker's main advantages is standardizing the application environment. Because the application and its dependencies are defined inside an image, it is possible to reduce differences between development, testing, and production environments.
Other advantages include:
- fast container creation;
- dependency isolation;
- portability;
- easy testing environments;
- suitable architecture for microservices;
- CI/CD integration;
- faster setup of development environments.
Are There Any Disadvantages to Docker?
Docker is not a technology that automatically solves every problem.
For beginners, learning concepts such as:
- Image;
- Container;
- Network;
- Volume;
- Registry
at the same time may initially seem complex. In production systems, networking, storage, logging, monitoring, and security need to be planned correctly. Because containers can be ephemeral, persistent data such as databases must be stored using an appropriate Volume strategy. For managing large numbers of containers at scale, orchestration platforms such as Kubernetes may be required in addition to Docker.
Where Should You Start Learning Docker?
When learning Docker, basic knowledge of Linux and the terminal can be useful.
After that, you can follow this learning path:
Container → Image → Docker CLI → Dockerfile → Volume → Network → Docker Compose → Registry → CI/CD → Kubernetes
At the beginning, running an existing image is a good starting point:
docker run hello-world
After that, you can create a Dockerfile for a simple Backend application and build an image. At the next stage, you can run PostgreSQL and the application in separate containers and manage them together with Docker Compose. This helps you better understand how Docker works in practice. Docker is not only about memorizing commands.
The main goal is to understand how:
- images;
- containers;
- filesystems;
- networking;
- persistence
work together.
If you want to learn Docker, Spring Boot, REST API, PostgreSQL, Microservices, CI/CD, and other modern Backend technologies through practical projects, you can explore JET Academy's Java Backend Programming Course. If you want to build Backend projects using Python, Django, PostgreSQL, Redis, NGINX, and Docker, you can also explore the Python Backend Programming Course.
