
Complete Docker Guide: Learn How to Create and Manage Containers for Scalable Applications
Docker has become an essential tool in the world of development and systems administration, allowing the creation, distribution, and execution of applications in isolated and consistent environments. In this comprehensive guide, we will explore from the basics of Docker to practical examples of different use cases, including content from Docker Hub.
Introduction to Docker
Docker is a lightweight virtualization platform that allows packaging and distributing applications along with all their dependencies in containers. A container is a software unit that includes everything needed to run an application, including code, runtime, libraries, and configurations.
Advantages of using Docker
- Portability: Containers can run on any machine that has Docker installed.
- Isolation: each container operates in an isolated environment, preventing conflicts between applications.
- Scalability: Containers can be easily replicated to handle variable workloads.
- Consistency: Ensures that the application works the same way in different environments.
Key concepts: images and containers.
- Image: Template that contains a filesystem and necessary configurations to run an application.
- Container: Running instance of an image. It is an isolated environment.
Docker Installation.
To install Docker, it depends on the operating system. It is available for Linux with any distribution such as Ubuntu, CentOS, Kali, etc., also available for Windows and MacOS. To install it, just follow the steps depending on the operating system you have at this link: https://docs.docker.com/engine/install/
Basic Docker Commands
docker run
The âdocker runâ command is used to run a container from an image. For example:
docker run -d -p 80:8080 nginx
This command runs a container based on the ânginxâ image in the background and maps port 8080 of the container to port 80 of the host.
đĄNote: The â-dâ detach flag is generally used to continue using our terminal, since if it is not used, you have to stop the container to continue using the command line.
docker ps
Shows a list of running containers.
docker ps
docker ps -a
Shows the list of containers that are running and stopped over time.
docker ps -a
docker images
Lists the images available on the system.
docker images
docker build
Builds an image from a Dockerfile in the current directory.
docker build -t "my-app"
docker stop and docker start
Stops and starts a running container.
docker stop "container-name"
docker start " container-name"
Creating and managing Images
A Dockerfile is a text file that defines how an image will be built. Example of a Dockerfile for a Node.js application
FROM node:18.17-alpine
WORKDIR /app
COPY package.json yarn.lock ./
RUN npm install
COPY . .
EXPOSE 3000
CMD [ "npm", "start" ]
Here we can see an example showing a series of instructions that our Dockerfile will have
- FROM: provides us with a base image. In this case, we take the 18.17-alpine image, which is much lighter than node 18.17
- WORKDIR: this is where our application will be hosted in the container
- COPY: adds the files from our local directory, all dependencies so that there are no errors when building
- RUN: creates the application with node:18.17-alpine
- EXPOSE: this is where our application will be exposed, in this case on port 3000
- CMD: Specifies which command we want to run in the container
đĄNote: there is another instruction called ENTRYPOINT, which is the entry to execute in the container; as an example, it would look like this
FROM node:18.17-alpine
WORKDIR /app
COPY package.json yarn.lock ./
RUN npm install
COPY . .
EXPOSE 3000
ENTRYPOINT [ "npm" ]
CMD [ "start" ]
Networks in Docker
Types of Networks in Docker
- Bridge: internal private network for containers on the same host.
- Host: Shares the host's network with the container
- Overlay: Multi-host network for communication between containers on different hosts.
Create and Manage Networks
docker network create "my-network"
Connect Containers to Networks
docker run -d --network="my-network" --name="my-container-nginx"
Data Persistence
Mounting Volumes in Containers
Allows data to persist even after stopping or deleting a container.
docker run -d -v "my-volume":/path/.../.../"my-container-nginx"
Data in Container vs Data in Volume
Data in the container is volatile and lost when the container is deleted. Data in a volume persists.
Copying data to/from Containers
docker cp file.txt "container-name":/path/.../.../container/
docker cp "container-name":/path/.../.../container/file.txt .
Practical Use Cases
Deploying a Web Application with Nginx
version: '3'
services:
 web:
  image: nginx
  ports:
   - "80:80"
Databases in Containers: MySQL and MongoDB
version: '3'
services:
 mysql:
  image: mysql:latest
  environment:
   MYSQL_ROOT_PASSWORD: mysecretpassword
 mongodb:
  image: mongo:latest
  volumes:
   - mongo-data:/data/db
volumes:
 mongo-data:
Isolated Development Environments
Creates consistent development environments for different projects
FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]
Container Orchestration with Kubernetes
Kubernetes is a powerful tool for container orchestration and management in a production environment
Exploring Docker Hub
Docker Hub is a public repository of container images, where individuals and companies can publish solution images.
Steps to Upload an Image to Docker Hub
The first thing you need to upload an image to Docker Hub is an account,
- Create your account on Docker Hub:
If you donât have your Docker Hub account yet, go to https://hub.docker.com/ and register
- Install Docker on your local machine:
To install Docker on your system, download and install it from the official website of Docker https://www.docker.com/get-started/
- Log in to Docker Hub from the command line
Open a terminal and use the following command to log in to Docker Hub with your username and password
docker login
You will be prompted to enter your Docker Hub username and password
- Tag the image you want to upload
Make sure the image you want to upload has an appropriate tag. You can tag the image using the following command
docker tag "name_image":tag "user_docker_hub"/"name_image":tag
Example:
docker tag my_app:v1 robpalacios1/my_app:v1
- Push the image to Docker Hub
Use the following command to push your tagged image to Docker Hub:
docker push "user_docker_hub"/"name_image":tag
Example
docker push robpalacios1/my_app:v1
- Verify the image on Docker Hub
After the image push is completed successfully, you can check the repository on Docker Hub, in the repositories section to make sure the image is available

đĄNote: As you can see, I have a React repository on my Docker Hub with different versions I have made in the code, and just by doing a pull to your local you can contribute to the code, similar to GitHub with the command docker pull robpalacios1/react-docker:<Tag>
Where Tag can be the versions I have from 1.0.0 up to the latest which is latest
Conclusion
Docker is a technology that has evolved the way we develop, deploy, and manage applications. From creating images to managing networks and volumes, Docker provides the necessary tools to build consistent and efficient environments.
Ready to take your applications to the next level with Docker?
At Kranio, we have experts in containerization and DevOps who will help you implement efficient solutions using Docker, optimizing your development processes and ensuring the scalability of your applications. Contact us and discover how we can drive the digital transformation of your company.
Previous Posts

Kraneating is also about protection: the process behind our ISO 27001 certification
At the end of 2025, Kranio achieved ISO 27001 certification after implementing its Information Security Management System (ISMS). This process was not merely a compliance exercise but a strategic decision to strengthen how we design, build, and operate digital systems. In this article, we share the process, the internal changes it entailed, and the impact it has for our clients: greater control, structured risk management, and a stronger foundation to confidently scale systems.

Development Standards: The Invisible Operating System That Enables Scaling Without Burning Out the Team
Discover how development standards reduce bugs, accelerate onboarding, and enable engineering teams to scale without creating friction.
