Docker Commands: A Complete Guide to Managing Containers

Last update: 18/03/2025
Author Isaac
  • Docker allows you to manage containers with commands essentials such as run, ps and stop.
  • Images form the basis of containers and are managed with pull, build, and rmi.
  • Volumes facilitate persistent storage with commands like volume create and rm.
  • Docker manages networks with tools like network create, connect, and rm.

Basic Docker Commands

Docker has become an essential tool for container management, facilitating application development in isolated and scalable environments. Understanding the most important Docker commands is crucial for navigating this platform with ease and maximizing its capabilities.

In this article, we'll explore the main Docker commands , from container management to handling images, volumes, and networks. Whether you're just starting out or want to deepen your knowledge, this is a complete and detailed guide to essential Docker commands.

Docker Architecture and Key Elements

Before we dive into the specific commands, it's important to understand the key elements that make up Docker's architecture:

  • DockerEngine: It is the central engine that allows the execution of containers.
  • Images: They are preconfigured templates that serve as a basis for creating containers.
  • Containers: They are instances of running images, which encapsulate applications and their dependencies.
  • Volumes: They allow data to be stored in a Persistent inside the containers.
  • Networks: They facilitate communication between containers and with the outside world.
Custom images with Dockerfile-3
Related articles:
How to create custom images in Docker with Dockerfile

Basic Commands for Managing Containers

Containers are the core of Docker. To manage them properly, you need to know the following commands:

  • docker run: run a contenedor from a image. Example: docker run -d --name mi_contenedor nginx.
  • docker ps: List the containers running. To see all containers, including stopped ones, use docker ps -a.
  • docker stop: Stops a running container. Example: docker stop mi_contenedor.
  • docker start: Start a stopped container. Example: docker start mi_contenedor.
  • docker restart: Restart a container. Example: docker restart mi_contenedor.
  • docker rm: Delete a stopped container. Example: docker rm mi_contenedor.

Container Management in Docker

Commands for Image Management

Images are fundamental in Docker, as they allow you to create consistent and reproducible environments . Some key commands are:

  • Docker images: List all the images stored in the system.
  • docker pull: Download a image from Docker Hub. Example: docker pull ubuntu.
  • docker build: build a image from a Dockerfile. Example: docker build -t mi_imagen ..
  • docker rmi: Delete one image specific. Example: docker rmi mi_imagen.
How to use Docker Compose-2
Related articles:
Complete guide to using Docker Compose

Volume Management in Docker

Volumes allow you to persistently store and share data between containers. Some essential commands are:

  • docker volume create: Create a new volume. Example: docker volume create mi_volumen.
  • docker volume ls: List all the volumes availables.
  • docker volume rm: Delete a specific volume. Example: docker volume rm mi_volumen.
  • docker run -v: Associate a costumes to a container. Example: docker run -v mi_volumen:/datos nginx.

Network Management Commands

Docker offers advanced network management options , enabling communication between containers and with the outside world:

  • docker network ls: List all the networks availables.
  • docker network create: create a new NETWORK. Example: docker network create mi_red.
  • docker network connect: Connects a container to a NETWORK. Example: docker network connect mi_red mi_contenedor.
  • docker network rm: Delete one NETWORK. Example: docker network rm mi_red.

Networking in Docker

Mastering these commands will allow you to work efficiently with Docker, optimizing the management of containerized applications. With this detailed guide, you now have the necessary tools to professionally manage images, containers, volumes, and networks within Docker.

Related articles:
How to fix error code 4294967295