Fundamentos de Docker
¿Por qué aprender Docker?
Diferencia entre Máquinas Virtuales, Contenedores y Servicios
Instalación de Docker
Conociendo Docker Desktop
Conociendo Docker CLI
Creación de Imágenes con Docker
Mi primera imagen de Docker
Creación de imágenes con Dockerfile
De mi imagen a un contenedor usando CLI
Administrar mis imágenes de Docker
Administrar mis contenedores de Docker
Mejorando mi Dockefile
Volúmenes y Redes de Docker
Configurar volúmenes básicos en Docker
Configurar redes básicas en Docker
Publicando Imágenes de Docker
¡Mi primera imagen en Docker Hub!
Inspección y capas de un contenedor
Guardar y recuperar imágenes de Docker
Orquestación de Contenedores de Docker
Introducción a Docker Compose
Despliega un conjunto de imágenes
Cierre del curso
Esto solo es el comienzo
You don't have access to this class
Keep learning! Join and start boosting your career
Creating a Docker image may seem challenging, but once you master the process, it makes it easier to distribute and deploy applications. The key is the Dockerfile, an essential file that defines the steps required to build a Docker image. From it, you can create an image that you can easily share. Here's how to do it.
Before building an image, it is essential to make sure that you are in the correct path in your terminal, where the Dockerfile is located. This can be verified using the ls
command in Linux. This command will list the files in the current directory, allowing you to confirm the presence of the required Dockerfile.
To start building the image, use the docker build .
command in your terminal. The dot (.) indicates that the Dockerfile is in the current location. When you run the command, Docker will read the instructions from the Dockerfile and start building the image, displaying the sequence of steps executed. You will see something like this:
docker build .
Docker will display the steps performed. For example, "1/2" might indicate that you are downloading a base image such as Nginx, and "2/2" will indicate that you are copying files to the image.
After creating your first image, when using docker images
, you might notice that the image appears unnamed and untagged. Although this is the fastest way to create an image, it is not recommended as it results in missing information. If it happens, consider deleting it with the command:
docker rmi -f <image-ID> .
This will delete your image permanently. Use -f
(force) in case the image has dependencies that might hinder its removal.
Labeling an image is basic to identify it easily. When building the image, use -t
followed by the name and tag:
docker build -t web-site:latest .
This gives it a name and a label ("latest" indicates the latest version). This way, you will be able to handle different versions of your images with clarity.
Once properly labeled, when listing images with docker images
, your new image will appear with the specified name and label, e.g. "sitio-web:latest". This makes it easy to manage multiple versions of an application or service.
With the image creation complete, you can now proceed to deploy to different environments starting with your local environment. This involves running containers based on the image you just built. Having properly labeled images simplifies your organization and the recycling of previous versions.
Dive into the world of Docker and keep expanding your skills. With each step you take, you will be better prepared to orchestrate containerized applications, a valuable skill in modern software development. Keep learning and exploiting the full potential of Docker!
Contributions 28
Questions 5
Want to see more contributions, questions and answers from the community?