If you work with Linux systems, you must have undoubtedly heard about the frequently used Docker commands. Simply put, Docker is a software that allows the creation of containers on the Linux system.
Thus, there are numerous Docker commands, which can be adopted. However, many professionals or beginners in the field are still confused about which are the basic commands most used in the field.
That’s why, thinking of helping you, we developed this complete content, with everything you need to know about Docker commands and their applications. Just read on and check it out!
As in any other area, to execute Docker functions there are several paths, possibilities and, consequently, commands.
But there are always the most used, with a simpler and more intuitive structure. After all, one of the main objectives of Docker technology is precisely to optimize processes, improve infrastructure, and guarantee system security.
In order for all these points to be achieved, basic commands, which perform indispensable functions, can be applied. We made a “top 8”, with these Docker commands below.
The Docker Run command basically creates a container with an image, even if that image is not stored on your host.
With it, the image is guaranteed to be inserted, since Docker Run is directed to the central repository and brings the image to its host in order to create the container in an appropriate manner.
The code structure to execute it is:
docker run [image name]
Unlike Docker run, Docker pull is responsible for downloading to the host the image found by Docker images (which will be explained later).
Its coded structure is equivalent to:
docker pull (parameter)
Thus, it is possible to insert the images into the host and then verify that the procedure was successful and the image stored.
As its name suggests, Docker create is responsible for creating a new container layer, which is writable, on top of the selected image, which can then be executed normally, using a command such as Docker run or start.
To better understand, it is enough to consider how the code structure is formed:
docker create [options] image [command]
At the end of the process, simply check whether the container status is evaluated as “created”, or created, translating into Portuguese. If so, your procedure was successful.
Totally contrary to the previous command, Docker stop is used to shut down or for a container created. The procedure will be executed and, if no response is received, the container will receive the command “sigkill” after 10 seconds.
The Docker stop structure is very simple and intuitive, just add the name of the container that you want to shut down or stop working:
docker container stop [container name]
It is necessary to correctly identify the container by its exact name, so that other containers with a similar name are not harmed or stopped.
This Docker ps command simulates the list command. This means that viewing all the containers created, for example, can be facilitated.
The structure of this command must be combined with the appropriate options according to your viewing needs and desire. The code used is:
docker ps [options]
Some available possibilities, which allow the combination of commands, are the options mentioned on the official website of the company Docker:
This command is responsible for creating an image using a file called Dockerfile and a contextualization, which represents the files located on the specified path or URL.
Its structure boils down to:
docker build [OPTIONS] PATH | URL | -
In this way, it is possible to create the image in a customized way, compressing construction contexts and considering some images constructed from a cache source.
To execute a command inside a container that is already running, it is necessary to resort to the help of the Docker exec command. Only it can start any command under these conditions.
Like the other command examples, Docker exec also features its own code structure:
docker exec [options] CONTAINER COMMAND [ARG…]
To complement its use, there is the possibility of adding options, with different functions, according to the table below, translated from the official Docker website:
Docker images is responsible for managing all container images and has a sequence of subcommands, such as:
All of these points have unique characteristics, in addition to completely specific functionalities and accesses for containers.
Also check out our content with all the main processes and commands in Linux .
The Docker concept may seem like a “seven-headed animal” to many beginners. Despite actually being a more complicated aspect of the entire Linux system, some professionals need to learn how to perform functions and perform tasks in Docker, such as developers.
So, thinking of helping you, the Linux Certification developed a complete Docker for DevOps course. With it, you can:
It is worth visiting and enrolling in this quality course, taught by a teacher who truly understands the subject and has over 15 years of experience with the Linux universe.
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.