Top 11 Docker Basic Commands

Docker Basic Commands Techhyme

Docker has revolutionized the way we build, ship, and run applications by leveraging containerization technology. With Docker, you can package your applications and all their dependencies into a single container, ensuring consistency across different environments.

To help you get started with Docker, here is a compilation of some basic commands that will empower you to work with containers efficiently.

1. `docker info`

The `docker info` command provides essential information about your Docker installation. It gives you details about the number of containers, images, networks, and other relevant system information.

docker info

2. `docker` command format

The `docker` command is the core of the Docker CLI (Command Line Interface). It allows you to interact with Docker and manage containers, images, networks, volumes, and more. The older format with double dashes `–docker` is still functional, but the more common usage is just `docker`.

docker [command]

3. `docker container run`

The `docker container run` command is used to create and start a new container from a specified image. By default, it runs the container in the foreground. To run the container in the background, you can use the `–detach` or `-d` option. Here’s an example of running an Nginx web server in the background and publishing port 80 on the host to port 80 in the container:

docker container run --publish 80:80 --detach nginx

4. `docker container ls`

The `docker container ls` command lists all the running containers. By default, it only shows the running containers. To see all containers, including the stopped ones, you can use the `-a` or `–all` option.

docker container ls
docker container ls -a

5. `docker container stop`

The `docker container stop` command is used to gracefully stop a running container. You need to provide the container ID or container name as an argument to this command.

docker container stop {container_id}

6. `docker container logs`

The `docker container logs` command allows you to view the logs generated by a specific container. You need to specify the container name or container ID as an argument to this command.

docker container logs {containerName}

7. `docker container top`

The `docker container top` command displays the running processes within a container. It provides valuable insights into the processes running in a specific container.

docker container top {containerName}

8. `docker container rm`

The `docker container rm` command is used to remove one or more stopped containers. However, if a container is running, the command will fail. To forcibly remove a running container, you can use the `-f` or `–force` option.

docker container rm {container_id}
docker container rm -f {container_id}

9. `docker container inspect`

The `docker container inspect` command provides detailed information about a container, including its configuration, network settings, and more.

docker container inspect {container_id}

10. `docker container stats`

The `docker container stats` command displays live performance statistics of a running container, such as CPU and memory usage.

docker container stats

11. `docker container update`

The `docker container update` command allows you to modify the configuration of one or more running containers. This is useful for changing container settings without stopping and recreating them.

docker container update --help

These basic Docker commands are just the tip of the iceberg. Docker provides a rich set of features and functionalities that can significantly simplify the development and deployment process of your applications. With time and practice, you will become more comfortable with Docker and unleash its full potential in your projects.

Happy containerizing!

Related Posts

File Permissions Linux Techhyme

Understanding Common File Permissions in Linux

File permissions are a fundamental aspect of file management in Unix-based operating systems like Linux. They play a crucial role in determining who can access, modify, or…

Linux System Key Components Techhyme

7 Major Key Components That Make Up A Linux System

Linux, an open-source operating system, has become one of the most widely used platforms due to its stability, security, and flexibility. It is comprised of various components…

File Finding Commands Linux Techhyme

Top 4 File Finding Commands in Linux

In the vast world of Linux, one of the most common tasks is finding files and directories scattered throughout the file system. Fortunately, Linux provides several powerful…

Informational Commands Linux Techhyme

Top 9 Essential Informational Commands in Linux

In the world of Linux, knowledge is power, and understanding the status of your system and its processes is crucial for efficient management and troubleshooting. Thankfully, Linux…

Linux File Tree Techhyme

Exploring the Linux File Tree: A Comprehensive Guide

In the world of operating systems, Linux stands out as a powerful and versatile option, favored by system administrators and users alike. One of the distinctive features…

Bash Shell Variables Techhyme

12 Most Commonly Used Bash Shell Variables

In the Linux shell environment, variables play a vital role in controlling and customizing the behavior of the system. Shell variables are placeholders that store information such…

Leave a Reply