Docker

[Cloud] 3. Docker Basic Commands

트리스탄1234 2023. 5. 23. 20:38
728x90
반응형

In this article, I will post about the commands for using Docker. First of all, if we look at the most basic command relationship of Docker, it is shown in the figure below.

First, let's run the command using the program installed in the Docker Overview blog post. If you type Virtualbox in the search bar of the window, the virtual machine program checked during the Boot2Docker installation is displayed. Click the corresponding icon

When you run it, the following screen appears. Click boot2docker as shown in the figure below and right-click on it.

As shown in the figure below, click Start ==> General Start to run boot2docker VM (Virtual Machine).

Then, a terminal will open as shown below and you will see the Docker logo.

You can now enter commands through this window. Now let's take a look at the basic commands used by Docker. ​ First, let's look at some basic commands. How to use the command

#doecker pull <<image name to receive>>

==> I bring the desired image from the Repository on the Internet to my PC. ​

#docker images ==> Displays images in my PC. ​

#docker rmi <<name>> ==> Deletes a specific image in my PC. ​

Now let's run the command.

1)docket pull nginx ==> Download web engine nginx image from Repogitory to my PC

2) docker images ==> Search images in my PC.

As you can see in the red box as a result of the inquiry, one image called nginx was downloaded. ​

3. Run the nginx image as a container with the command

docker run -it --name webengine nginx /bin/bash

==> The --name option is followed by the container name you want to use, followed

by the image name.

You can see that the prompt (root@boor2docker:~#) has been changed (root@04fbab14b7:\#) before executing the run command. This means that the current location is inside the container you just launched. That is, if you execute a command in this state, it means that it is executed in the container, not in boot2docker . ​

4. Enter ctrl + p + q to exit the container.

You can see the prompt changed back to boot2docker. If you exit from the container and execute the command in the current location, it will be executed in boot2docker instead of in the container. ​

5. docker ps -a ==> Shows the information of the currently running container.

6. docker attach <<container name>> ==> This is a command to reattach to the inside of the container.

7. You can see the prompt changed back to inside the container. Press crtl + p + q to exit again.

8. docker exec webengine echo "Hello docker" ==> Send command to output "Hello docker" from docker to container.

The container (webengine) delivers the result to docker after executing the command. ​ 9. Let's stop the container with docker stop <<container name>>.

- You can start a container with docker start <<container name>>.

- You can restart the container with docker restart <<container name>>

If you look at the status status, before stop, it was up, and after stop, the result value is output as exited. ​

10. Let's delete the container with the docker rm <<container name>> command.

As a result of deleting webengine with the docker rm command and querying the running container with the docker ps -a command You can see that there are no containers currently running. ​

11. Delete the downloaded image called nginx with the docker images <<image name>> command.

You can confirm that the image has been deleted with the docker rmi nginx command. ​

12 Use the docker search ubuntu command to search the ubuntu image stored in the Docker Repogitory (https://registory.hub.docker.com).

Shows a list of many downloadable images. ​ The basic commands will be posted here. For docker commands, refer to the link below.

https://docs.docker.com/engine/reference/commandline/

728x90
반응형

'Docker' 카테고리의 다른 글

[Cloud] 6. Using Dockerfile  (67) 2023.05.31
[Cloud] 4. Docker Network  (89) 2023.05.28
[Cloud] 5. Docker Registry  (36) 2023.05.26
[Cloud]2. Configuring your Docker environment  (69) 2023.05.20
[Cloud] 1. Docker Overview  (65) 2023.05.18