Skip to content
Updated: 11 min read

Docker for Beginners: How to Quickly Get Started with Containers

Entering the world of modern software development and deployment often involves the need to master new tools and concepts. One technology that has...

Marcin Godula Author: Marcin Godula

Entering the world of modern software development and deployment often involves the need to master new tools and concepts. One technology that has fundamentally changed the way we build, test, and run applications is Docker. If you are just starting your adventure with containerization or looking for an organized introduction to this technology, this article is for you. We will explain what Docker is, why it has gained such great popularity, and how you can quickly take your first steps working with containers. We will focus on practical basics that form the foundation of knowledge conveyed in introductory training, so you can effectively begin your journey with Docker.

What Is Containerization and Why Should You Know Docker?

Before we delve into Docker itself, it’s worth understanding the idea of containerization. This is a method of virtualization at the operating system level that allows “packaging” an application along with all its dependencies (libraries, configuration files, runtime environment) into an isolated unit called a container. Such a container can then be easily transferred and run on any machine that has the appropriate environment for handling containers, regardless of its operating system or installed software.

Docker is currently the most popular platform for creating, managing, and running containers. It provides a set of tools and an ecosystem that significantly simplifies the containerization process. Why is it worth knowing? Because it solves many common problems in the software lifecycle. It eliminates the “it works on my machine” syndrome by ensuring environment consistency between developer machines, test servers, and production. It accelerates the application deployment process, facilitates scaling, and optimizes server resource utilization. Knowledge of Docker is increasingly becoming a standard requirement in many technical roles, from developers to system administrators and DevOps engineers.

How Do Containers Differ from Virtual Machines?

A question that often arises is about the difference between containers and virtual machines (VMs). Both technologies serve to isolate applications and their environments but do so in fundamentally different ways. A virtual machine emulates a complete hardware system (processor, memory, disk, network card), on which a full operating system (called a guest system) is installed, and only then is the application run. Each VM has its own operating system kernel.

Containers, on the other hand, work differently. They use the shared operating system kernel of the host on which they run. Isolation occurs at the level of processes and operating system namespaces. This makes containers much “lighter” - they start instantly (in milliseconds or seconds, not minutes like VMs), take up less disk space, and consume less RAM and computing power. This allows running significantly more containers on the same hardware compared to virtual machines. This resource efficiency is one of the key advantages of containerization.

What Are the Basic Docker CLI Commands You Need to Know?

Interaction with Docker occurs mainly through the command line interface (CLI). There are several fundamental commands that will allow you to start working:

  • Image management: The basic command for downloading images from a repository (e.g., Docker Hub) is docker pull IMAGE_NAME:TAG. To see the list of images available locally on your machine, use docker images. To remove an unnecessary image, use docker rmi IMAGE_NAME_OR_ID.

  • Running containers: To run a container based on an image, use the docker run IMAGE_NAME command. Often you add options to it, e.g., -d to run in the background (detached mode) or -p HOST_PORT:CONTAINER_PORT to publish a container port on the host.

  • Container management: The list of currently running containers is displayed using docker ps. To see all containers (including stopped ones), add the -a flag: docker ps -a. To stop a running container, use docker stop CONTAINER_NAME_OR_ID, and to restart it, docker start CONTAINER_NAME_OR_ID. Removing a stopped container is done with the docker rm CONTAINER_NAME_OR_ID command.

Mastering these few basic commands is an important first step in learning practical Docker usage.

What Are Docker Images and How Do You Manage Them?

A central element of the Docker ecosystem is images. A Docker image is a lightweight, standalone, executable package that contains everything needed to run an application: code, runtime environment, system tools, libraries, and settings. Images are created in layers, meaning changes in subsequent layers are saved as differences, which optimizes their size and speeds up building and downloading.

Images are immutable - once built, an image does not change. Based on one image, you can run many containers, which are running instances of that image. You can think of an image as a template or class in object-oriented programming, and a container as an object created from that class.

Images are stored and shared using registries. The most well-known public registry is Docker Hub, where you’ll find thousands of ready-made images for popular technologies (e.g., databases, web servers, programming languages). You can also create your own private registries to store company images. Managing images mainly involves downloading them from registries (docker pull), listing local images (docker images), building your own images (more on that shortly), and removing them (docker rmi) when they’re no longer needed.

How Do You Create Your Own Images Using Dockerfile?

Although you can use ready-made images publicly available, there is often a need to create your own custom image containing your application and its specific configuration. For this purpose, a text file called Dockerfile is used.

A Dockerfile contains a set of instructions that step by step describe how to build an image. Each instruction creates a new layer in the image. Basic instructions you’ll find in most Dockerfiles include:

  • FROM BASE_IMAGE_NAME: Specifies the base image on which the new image will be built (e.g., FROM python:3.9-slim).
  • WORKDIR /path/in/container: Sets the working directory for subsequent instructions (e.g., WORKDIR /app).
  • COPY local/path /path/in/container: Copies files or directories from your machine (build context) to the image file system (e.g., COPY . . will copy the entire contents of the current directory).
  • RUN command: Executes a command inside the image being created, e.g., to install dependencies (RUN pip install -r requirements.txt).
  • EXPOSE PORT: Informs Docker that the container will listen on a specific port (e.g., EXPOSE 8000). Does not automatically publish the port.
  • CMD ["command", "param1", "param2"] or ENTRYPOINT ["command"]: Defines the default command that will be executed when starting a container from this image (e.g., CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]).

To build an image based on a Dockerfile, use the command docker build -t your_image_name:tag . (the period at the end indicates the current directory as the build context). The ability to create your own Dockerfiles is key to effectively deploying your own applications using Docker.

How Do You Work Interactively with Containers?

Besides running containers in the background (docker run -d), you often need to interact with a running container, for example, to debug, execute one-time commands, or view its file system. Docker provides appropriate tools for this.

To run a container in interactive mode and immediately gain access to its shell, you can use the -it flags (combining -i for interactive mode and -t for pseudo-terminal) in the docker run command, e.g., docker run -it ubuntu bash will start a container from the Ubuntu image and immediately enter its bash shell.

If a container is already running in the background, you can execute an additional command in it using docker exec. For example, docker exec -it CONTAINER_NAME_OR_ID bash will let you enter the bash shell of the running container. You can also execute a single command without entering the shell, e.g., docker exec CONTAINER_NAME_OR_ID ls /app will display the contents of the /app directory inside the container.

To view the logs generated by a container, use the command docker logs CONTAINER_NAME_OR_ID. You can use the -f flag to follow logs live (docker logs -f ...). The ability to work interactively with containers is invaluable during development and problem diagnosis.

What Does Basic Network Communication in Docker Look Like?

Containers, to be useful, must be able to communicate with the outside world and with each other. Docker provides built-in networking mechanisms that enable this. By default, Docker creates a bridge type network named bridge. Containers connected to the same bridge network can communicate with each other using their internal IP addresses.

To allow access to services running in a container from outside the Docker host (e.g., from your browser), you must publish the container port on the host machine port. This is done using the -p or --publish flag when starting the container: docker run -p 8080:80 nginx will start a container with an Nginx server and redirect traffic from port 8080 on the host machine to port 80 inside the container. This way, by typing http://localhost:8080 in your browser, you’ll access the page served by Nginx in the container.

Docker also allows creating custom networks (e.g., other bridge networks or overlay networks in Swarm mode), which gives greater control over isolation and communication between containers. Understanding basic networking concepts is important for building applications consisting of multiple containers.

What Practical Benefits Does Docker Knowledge Provide?

Mastering Docker basics opens doors to many practical benefits, both in daily work and career development. Above all, you gain the ability to efficiently create consistent and portable environments for your applications. Whether you’re a developer, tester, or administrator, Docker allows you to avoid problems related to configuration differences between machines.

Knowledge of Docker significantly simplifies and accelerates the application deployment process. Containerized applications can be easily run in any Docker-supporting environment, which shortens the time needed to prepare and configure servers. It also facilitates implementing Continuous Integration and Continuous Deployment (CI/CD) practices.

Additionally, containers allow for better utilization of hardware resources compared to traditional virtual machines, which can lead to infrastructure cost savings. The ability to work with Docker is also increasingly valued in the IT job market, opening new career opportunities in areas such as DevOps, Cloud Engineering, or systems administration.

Summary: Build Solid Docker Foundations with EITT

Docker has revolutionized the way we approach creating, testing, and deploying software. Understanding it and mastering it practically is becoming a key skill for every IT professional. In this article, we presented the absolute basics: the concept of containerization, differences from virtual machines, key Docker CLI commands, working with images and Dockerfiles, interacting with containers, and networking basics. This is a solid starting point for further learning.

If you want to systematize your acquired knowledge, practice the discussed concepts in practice under the guidance of an experienced trainer, and build solid foundations that will allow you to confidently use Docker in daily work, we invite you to check out the “Practical Applications of Containerization with Docker” training at EITT. Our introductory training is designed to guide you through all the key aspects of working with Docker in an accessible and practical way, giving you the skills necessary for an effective start.

Contact us or check the training details on our website to learn how we can help you begin your adventure with containerization and Docker!

Read Also

Develop Your Skills

This article is related to the training Podman Containers - Alternative to Docker. Check the program and sign up to develop your skills with EITT experts.

Frequently Asked Questions

What are the system requirements for installing Docker?

Docker Desktop runs on Windows 10/11 (with WSL 2 or Hyper-V), macOS 12 or newer, and most modern Linux distributions. You need at least 4 GB of RAM, though 8 GB or more is recommended for running multiple containers simultaneously.

Can Docker containers run on any operating system?

Docker containers share the host operating system kernel, so Linux containers run natively on Linux and through a lightweight VM on Windows and macOS. Windows containers exist but can only run on Windows hosts, making Linux containers the most portable option across platforms.

How is Docker different from Docker Compose?

Docker manages individual containers, while Docker Compose is a tool for defining and running multi-container applications using a YAML configuration file. Compose is ideal when your application requires multiple services working together, such as a web server, database, and cache layer.

Is Docker suitable for production environments or only for development?

Docker is widely used in production environments by organizations of all sizes. Combined with orchestration tools like Kubernetes or Docker Swarm, it provides automated scaling, load balancing, and self-healing capabilities that make it well-suited for production workloads.

Read also

Request a quote

Develop Your Competencies

Check out our training and workshop offerings.

Request Training
Call us +48 22 487 84 90