Welcome to the world of modern technology! If you’re a beginner in programming or system administration, you’ve probably heard the word Docker constantly. It might sound complicated, but the truth is that Docker was created to make our lives easier, not harder.
In this first part of our series, we’ll journey from "What is this?" to launching an entire infrastructure with Docker Compose. And we’ll do it the professional way – directly on a server.
This article is a translation of the original Bulgarian article: Docker & Docker Compose: от нулата до сървър
1. The Problem: "It Works on My Machine!" 😫
Imagine you’ve written an amazing program. It works perfectly on your laptop. You send it to a client or up…
Welcome to the world of modern technology! If you’re a beginner in programming or system administration, you’ve probably heard the word Docker constantly. It might sound complicated, but the truth is that Docker was created to make our lives easier, not harder.
In this first part of our series, we’ll journey from "What is this?" to launching an entire infrastructure with Docker Compose. And we’ll do it the professional way – directly on a server.
This article is a translation of the original Bulgarian article: Docker & Docker Compose: от нулата до сървър
1. The Problem: "It Works on My Machine!" 😫
Imagine you’ve written an amazing program. It works perfectly on your laptop. You send it to a client or upload it to a server and... boom! Nothing works. It turns out the server has a different version of Python, a library is missing, or the database settings are different.
This is called an "environment conflict." Before Docker, programmers wasted hours (and days) configuring servers.
The Solution: The Digital Container 📦
Docker takes your program and encloses it in a "container." Inside this container is everything needed:
- The code itself
- The libraries it uses
- System settings
When you give this container to someone else, it works in exactly the same way because the operating system on the computer no longer matters. Docker provides isolation.
2. Preparation: Where Will We Work? 🌐
To learn Docker properly, you need to use it where it belongs – on a Linux server.
Many tutorials start with Windows installation (Docker Desktop), but this often confuses beginners with additional BIOS settings, virtual machines, and unnecessary RAM consumption. That’s why we’ll take the professional approach.
Step 1: Server Access
If you have your own server (VPS) with Ubuntu, great! If you don’t, you can rent one for a few euros per month from providers like DigitalOcean, Hetzner, or local ones.
Connect to your server via terminal (PowerShell on Windows or Terminal on Mac):
ssh root@your-ip-address
3. Professional Installation (All at Once) 🛠️
Forget long guides. Docker provides an official script that does everything for you. Once you’ve logged into the server, simply copy and paste this:
curl -fsSL https://get.docker.com -o install-docker.sh
sudo sh install-docker.sh
What just happened?
- You downloaded the installation script
- You executed it with administrator privileges
- Docker is now installed and ready to work
To check if everything is okay, type:
docker --version
If you see a version (e.g., Docker version 24.x.x), you’re ready for the magic! ✨
4. The Three Pillars of Docker: Image, Container, Registry 🏗️
Before we start something, you need to understand three basic concepts:
- Image: This is a "frozen" snapshot of your program. It doesn’t do anything, just sits on disk. Think of it as a cake recipe.
- Container: This is the actual cake. When you "start" the image, it becomes a live, working process (container). You can create 100 containers from the same image.
- Registry: The place where images are stored. The biggest is Docker Hub – it has ready-made images for everything: databases, web servers, programming languages.
5. Your First Container: Web Server in 5 Seconds 🚀
Let’s run Nginx – the most widely used web server in the world. On a regular server, its installation takes time and configuration. With Docker, it’s one command:
docker run -d -p 80:80 --name my-site nginx
Command Breakdown (Important!):
docker run: Tells Docker to find the image and start it-d: (Detached) Means "run in the background." Without it, your terminal will be blocked by server logs-p 80:80: This is critical! The first80is your server’s port. The second80is the port inside the container. We’re saying: "When someone visits my IP, forward them to the container"--name my-site: We give it a name so we can recognize itnginx: The name of the image we’re pulling from Docker Hub
Result: Open your browser and type your server’s IP address. You should see: "Welcome to nginx!". Congratulations, you’re a system administrator! 😎
6. How to Manage the Chaos? (Survival Commands) 🕹️
Now that something is running, we need to know how to control it.
- See which containers are currently running:
docker ps
- See all containers (even stopped ones):
docker ps -a
- Stop the server:
docker stop my-site
- See what’s happening "inside" (Logs):
docker logs my-site
(If something doesn’t work, this is where you’ll see why)
7. The Grand Finale: Docker Compose 🎼
One container is easy. But what do we do if we need a website (Nginx) + database (MySQL)? Writing two long docker run commands and manually connecting them is torture.
This is where Docker Compose comes in. It allows you to describe your entire infrastructure in one file.
Step 1: Installation
On modern systems, it comes with Docker, but check with:
docker compose version
Step 2: Creating the Project
Create a folder for your project and enter it:
mkdir my-app && cd my-app
Now create a file named docker-compose.yml. You can use the nano editor:
nano docker-compose.yml
Put this code inside:
version: '3.8'
services:
web:
image: nginx
ports:
- "8080:80"
database:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: your-password-here
(Press Ctrl+O, Enter, then Ctrl+X to save and exit nano)
Step 3: The Magic Begins
Instead of starting things one by one, just write this:
docker compose up -d
What happened? Docker Compose read the file, understood you need two containers, created a virtual network between them, and started them simultaneously. Now you have a working web server on port 8080 and a database underneath it.
To stop and delete everything at once:
docker compose down
8. Why Did This Work "Right Away"? 💎
If you followed the steps, you probably already have a working system. Here are the secrets to success:
- Clean server: When we work on clean Linux, there are no conflicts with Windows settings
- YAML syntax: Be careful with indentation in
docker-compose.yml– it matters! Don’t use Tab, only spaces - Ports: If port 80 is occupied, you can always change it to 8081 or 8082
Conclusion and Next Steps
Today you learned the basics of the most important technology for cloud services. You now know how to:
- Install Docker professionally
- Start ready-made programs (Images) as containers
- Orchestrate complex systems with Docker Compose
In the next article, we’ll move to the next level: How to package our own software. We’ll write our first Dockerfile and turn simple code into a professional Docker image.
About the Author: Fedya Serafiev is the creator of ITpraktika.com – a platform dedicated to practical IT solutions and automation. With extensive experience in system optimization and web technologies, he transforms complex technical cases into clear and easy-to-follow steps.
Original Article (Bulgarian): Docker & Docker Compose: от нулата до сървър
Related Links:
💝 If you found this article useful, consider supporting my work:
💖 Your support means a lot!