AWS Builder Center

How to create your first Docker container and why it changes everything in DevOps

Learn the fundamental concepts of Docker in a simple way. Understand how to package your application so it runs perfectly in any environment, from your local machine to the cloud.

Introduction
In the world of software development and DevOps, there is a classic phrase that every professional has heard or said: It works on my machine. This problem usually happens because the development environment on the programmer's computer is different from the production environment on the server. Docker was born precisely to solve this challenge by isolating the application and ensuring it works the exact same way anywhere.
What is Docker and why it is essential in DevOps
Imagine Docker as a cargo ship system. Instead of placing loose goods on the ship, you use standardized containers. In software, it is the same thing. Docker packages your application code along with all the dependencies, libraries, and configurations it needs to run. This package is called an image, and when we put this image into execution, we get a container.
For the DevOps culture, this brings agility in delivery, ease in creating automation pipelines, and total consistency between testing and production environments.
The three fundamental concepts you need to know
The first concept is the Dockerfile. It is just a simple text file where you write your recipe, meaning the step-by-step instructions to build your application.
The second concept is the Image. The image is the final result after Docker reads your Dockerfile. It works like a closed file that cannot be modified.
The third concept is the Container. The container is the image in action. It is the isolated and live environment running your system on the server.
Step-by-step to run your first container
To start, the first step is to install Docker Desktop on your computer. Once installed, you can open your operating system terminal to interact with it.
The second step is to test if everything is working correctly. To do this, type the command docker run hello world and press enter. This command makes Docker look for a test image on the internet, download it to your computer, and run it. If a success message appears on your screen, your environment is ready.
The third step is to understand how to run a real application, such as a website server. You can type the command docker run d p 8080 80 nginx. This command downloads the Nginx server, runs it in the background, and directs access to your computer. If you open your internet browser and type localhost on port 8080, you will see the server's home page working.
Conclusion and next steps
Mastering Docker is the mandatory first step for anyone who wants to work with DevOps and the cloud. It simplifies deployment and serves as the foundation for more advanced technologies you will find in the market, such as Kubernetes and Amazon ECS.
As next steps in your journey, try creating your own Dockerfile to package a simple application that you developed yourself.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article