Post Image
By Daniel Tanque25 de Outubro, 2023In DevOpsDockerLearning

Docker Basic Commands

Docker is a popular platform for developing, packaging, and deploying applications inside lightweight, self-contained containers. These containers are similar to virtual machines but more efficient and portable. Docker is used to package an application and its dependencies into a single unit called a container, ensuring that the application runs consistently across various environments, from a developer’s laptop to a production server.

In this article you will learn which are the basic commands to run containers, download, pull, remove images and how to manage containers.

Operating containers

To run a container from an image you use:

docker run <name of the image>

To list all containers running:

docker ps

To list all containers running or not:

docker ps -a

To stop a container you can run:

docker stop <container name || container id>

To check all the images present in your system you can run:

docker images

To remove images you have first to stop running containers that use that image and then:

docker rmi <image name>

To run a command on a container you can run:

docker exec <name of the container> <command>

One important thing to have in mind is that the docker runs attached if you just type “docker run <name of the image>” you can run it in detached mode:

docker run -d <container name>

To access the bash of a container you can run:

docker run -it centos bash

To provide a name for the container you can run:

docker run -d --name <insert the desired name> <image name>:<id>


Now you know how to basically operate your container. Well done!

svgClean Code - Intention Revealing Names
svgDocker - Interoperability

Leave a reply