
Diogo Barros
Criado em 2 Dec 2025 • 12 min(s) de leitura
Atualizado há 2 semanas
Hoje meus queridos vamos fazer a nossa maravilhosa ✨Introdução ao Docker✨.
Sim, aquela ferramente que todo o developer diz saber (mas não sabe), aquele extra que aparece nos job posts para quem tem medo de contratar um engenheiro DevOps, eis o tutorial que vos vai iniciar no mundo do Docker e mais além!!
- Because modern DevOps thrive on containerized environments.
And y’all like “contaienrexdzçe what?”. Yes, containers. We have to learn what those are, in a little bit!
Docker brings in:
- Knowledge from all main things in DevOps and Cloud (because in containers, you work a lot with linux, networks, and fully understand how apps are shipped and deployed)
- The right mindset - if you work with the mindset of containers, you start to shift your mindset to work with containers instead of just applications, and really start to grasp how in the modern world we update, rollback, etc - meaning there are a lot of advantages to mastering Docker.

Sit back, and relax, and enjoy your lesson! ✈
What is Docker?
It is a tool that can package software into containers that run reliably in any environment.
Can I install docker in this PC? Then, I can run this software!
And what is a container, and why do you need one?
Let's imagine you built an app with php that runs on some old/specific flavor of Linux. You want to run this app in your company, but it has another flavor of Linux, and the app doesn’t run.

You showing your “cool automation” to your friend at work.
This brings the question: how do we replicate the environment our software needs on any machine? That’s what Docker is here to solve:
T package an app is with a virtual machine, where the VM is working on “virtualized” hardware. It thinks it’s actually operating hardware, but it’s actually just a process in the host machine that fakes hardware calls.
This allows us to run ✨ multiple apps ✨ on the same infrastructure (computers/servers). However, because each VM is running its own operating system, they tend to slow down.
Let’s cover some topics for context later in the game:
Operating Systems (OS) 🖥️
An Operating System is the core software that manages a computer's hardware resources (CPU, memory, disk, network) and provides common services and apps.
Kernel
The Kernel is the core component of the Operating System. It is the bridge between application software and hardware. It manages processes, memory, and writes/reads in disk.
Process
A Process is an instance of a computer program that is being executed. Every running process is assigned a unique Process ID (PID) by the kernel.

Virtual Machines (VMs)
A VM emulates an entire computer system (including hardware, a full operating system, and a kernel) on top of existing hardware, using a Hypervisor. They offer strong isolation but require significant resources.

Containers
Now, a Docker container is conceptually very similar to a VM, with one key difference. Instead of virtualizing hardware, containers only virtualize the OS.
Containerization means virtualizing an OS, package an application, its configuration, and all its dependencies into a single, isolated unit. Crucially, all containers running on a host share the host OS kernel, making them fast and lightweight.

Containers are just a bunch of processes “pretending” they don’t exist (by isolating their files, networking and processes).

Since I’m a container, I’ll just pretend other processes don’t exist!
There are three fundamental elements in the universe of Docker:
- Dockerfile - The DNA of an image. it tells Docker how to build the image
- Image - (a read-only file that captures all the software, dependencies, OS)
- Container - A running instance of the image
The Docker Engine
The Docker Engine is the core software that builds Docker Images, runs containers, and manages the resources (volumes, networks, etc.). It consists of a server (Docker Daemon), a REST API, and a command-line interface (CLI).
On Windows/MacOS, it uses a Virtual Machine 😭😭😭😭
(For Windows and macOS) Docker uses a lightweight Linux-based Virtual Machine to host the Docker Daemon because containers are a Linux-native technology, relying on the Linux kernel features (Namespaces and cgroups). I’m surprised at the amount of people not knowing this!
Fun fact - most modern Kubernetes clusters run containers, but Docker itself is no longer the runtime. Containers are still containers, but the machinery underneath changed.
To proceed, you need to install Docker:
- Are you using Windows or Linux? Install
Docker Engine - Are you using a Macbook? Install
Orbstack- a modern all-in-one solution for MacOS.
All right, let’s get our hands dirty. 🤺
🏃 Running containers
The core command for launching an instance of an image is docker run.
A container is a running instance of an image.
Running a Minimal Utility Container (Ubuntu)
To quickly test Docker or run a simple command within a minimal Linux environment, you can use the Ubuntu image.
- When you run the following command, Docker first checks if the
ubuntuimage is available locally. If not, it usesdocker pullto download it from Docker Hub. - The options used here allow you to interact with the container:
it: Stands for Interactive Terminal, ****which allows you to type commands inside the container's shell.-rm: Automatically removes the container filesystem when the container exits, keeping your system clean.
Your final command:
docker run -it ubuntu
Now, you can perform cool linux commands inside of the container! Try top, for example!

The linux penguin is proud of you!
Running a Web Server Container (Nginx)
The Nginx image is a standard example for running a lightweight web server. When running web applications, you must use port mapping to make the service running inside the container accessible from your host machine.
- The Nginx image is configured to expose the service on port 80 internally.
- We use the
pflag to map a port on your host (e.g.,8080) to the container's internal port (80). - The
dflag runs the container in detached mode, meaning it runs in the background and doesn't tie up your terminal.
Your final command:
docker run -d -p 8080:80 nginx

The NGINX logo is also super proud of you!!! 💚
👣 Review your Knowledge 👣
But first, let’s review all the concepts.
A Docker Image is the read-only template or blueprint for a container. A Container is a run-time instance of an Image.
Containers start (almost) empty
…and there are many minimal operating systems. The "minimal operating systems" are your Base Images (e.g., Alpine, Debian Slim). They are minimal because they only contain the absolute necessities. Images are built in layers, starting from a base image and adding the application's dependencies and code on top.
Your actual image (in production)
Our final result is equal to a sum of:
- An existing image (The Base Image, e.g.,
python:3.10-slim-buster). - A runtime environment (e.g., The Python interpreter, Node.js runtime, Java JRE, already included in the base image or added in subsequent layers).
- A build or code to run (Your application source code and configuration files).
🎁 The sum is a read-only, ordered collection of filesystem layers that, when combined, make up the container’s root filesystem. This is what makes the image.
✨ Super Mini パワフル Mega Command Recap!
| Action | Command |
|---|---|
| Pull Nginx | docker pull nginx |
| Run Nginx | docker run -d -p 8080:80 nginx |
| List running containers | docker ps |
| View Nginx logs | docker logs <container_id> |
🖥️ Testing the Pagerino App Locally
https://github.com/professordiogodev/pagerino
Here’s the git repository with your initial code.
Before containerizing an application, it's often essential to test the software directly on your computer's host operating system to ensure it works correctly without the complexities of Docker.
The provided files represent a simple static web application called "Pagerino", consisting of a main HTML file and a styling CSS file.
Pagerino File Contents
Here is a summary of the files that make up the Pagerino app:
index.html: This is the main page for the application.- It displays the heading "🚀 Pagerino Container Active 🐳".
- It links to the external stylesheet,
style.css. - It confirms the app is successfully serving content.
style.css: This file provides a dark, tech-friendly, monospace aesthetic with gradient background and neon green accents. It also includes CSS for:- A status light.
- A version tag reading "Nginx/Alpine".
- An animation that makes the Docker whale emoji "float" and "spin".
Moving to Containerization (Building the Image)
Once the local app is confirmed to be working, the next step is to create a Docker Image for it. This is done using a Dockerfile.
Dockerfile: This file contains the instructions to build the Pagerino image.FROM nginx:alpine: It starts from the lightweight Alpine version of the Nginx web server image.COPY: It copies the localindex.htmlandstyle.cssfiles into the Nginx serving directory (/usr/share/nginx/html/).EXPOSE 80: It documents that the application will run on port 80.
Creating our own Image
You create your image by writing a Dockerfile and running the docker build command.
A Dockerfile is a simple, plain-text file that contains a series of instructions (commands) that Docker reads to automatically build a container image.
Dockerfile overview
Key instructions in a Dockerfile:
FROM: Specifies the base image for the build (e.g.,FROM python:3.10-slim).RUN: Executes a command during the image build to install packages or dependencies.COPY: Copies local files (your app code) into the image.EXPOSE: Documents the port the application runs on (e.g.,EXPOSE 5000).CMD/ENTRYPOINT: Defines the default command to run when the container starts.
For pagerino, we have the example already built for us:
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
COPY style.css /usr/share/nginx/html/style.css
EXPOSE 80
Useful commands
| Action | Command |
|---|---|
| Build the Image | docker build . -t my-app:v1 |
| Check Running Containers | docker ps |
| Check Container Output | docker logs <container_id> |
Now we can create the image file by running the docker build command. It goes through each step in our Dockerfile to build the image layer by layer. We can then bring this image to life as a container with the docker run command. As your app demands more resources, you can run it on multiple machines, multiple clouds, on-prem, or wherever you want, reliably.
All right, let’s build this!
docker build . -t <your-username>/pagerino
We can also run it!
docker run -d -p 8080:80 nginx
Now, it’s time to publish our image.
You publish your image by tagging it and then pushing it to a Container Registry, such as Docker Hub (the most popular public registry), GitHub Container Registry (super popular in 2025), AWS, Azure, etc.
docker push <your-username>/pagerino

Your old app running deploying and running super quick on modern AWS virtual machines.
That’s it! 🔥 YOU’VE DONE IT! Let’s give it another try, but using Python with flaskeritto. And really, while Docker will take practice to master the specifics and main errors that happen all the time, you can be proud of yourself for understanding concepts that SO MANY engineers (trust me I’ve had to hire engineers 😑) working with DevOps aren’t aware of.
https://github.com/professordiogodev/flaskeritto
Extras
🔨 Containerize yet another app (try noderissimo!) 🔨
Run this in an actual cloud virtual machine
Create a VM in AWS or Azure, and connect to it. Now, you need to install Docker in the machine. Make sure to allow port 80, and boom!
To quickly install docker in a cloud VM, run curl -fsSL https://get.docker.com | sudo sh.
Note: If you’re using a Macbook with Apple Silicon, you have to build and push with a special command (to run everything on most windows machines):
docker buildx build --platform linux/amd64,linux/arm64 -t pokfinner/flaskeritto --push .
At Ironhack, we run mini apps (like flaskeritto) to prepare students with different stacks (python, java, etc.) by the time they reach their daily DevOps Engineering job.
In less than 60 minutes, you nailed more info about how docker principles than most DevOps Engineers in the junior market.
In a little over two months, Ironhack will place you in the top of the job market.

Go ahead, try me!
If you go there will be trouble:
- Keep wandering without a clear focus
- Risk falling behind (to competition, to AI)
And if you stay, it will be 🔥double🔥:
- An intense experience giving you everything you need to know
- Start thinking and engineering like an architect
- You position yourself in the top 15% Juniors
With love 💙,

Diogo Barros

Também te podes interessar por estes artigos...





