Docker basic operation usage -- other common commands

Chen Bucheng I 2022-06-24 07:27:14 阅读数:296

dockerbasicoperationusagecommon

7、 ... and . Release image file

After the container runs successfully , Just confirmed image Validity of documents . At this time , We can consider image File sharing online , Let others use .

First , Go to hub.docker.com or cloud.docker.com Sign up for an account . Then log in with the following command . docker login

Then for local image Mark user name and version . docker image tag [imageName] [username]/[repository]:[tag]

example docker image tag koa-demos:0.0.1 ruanyf/koa-demos:0.0.1

You can also not mark the user name , Rebuild image file . docker image build -t [username]/[repository]:[tag] .

Finally release image file docker image push [username]/[repository]:[tag]

After publishing successfully , Sign in hub.docker.com, You can see the published image file .

8、 ... and . Other useful commands

1.docker container start

Ahead docker container run The command is to create a new container , A new container is created each time it runs . Run the same command twice , As like as two peas, two identical container files will be generated. . If you want to reuse the container , Then use docker container start command , It is used to start the generated 、 Container files that have stopped running . docker container start [containerID]

2.docker container stop

Ahead docker container kill The command terminates the container run , It is equivalent to sending a message to the main process in the container SIGKILL The signal . and docker container stop The command is also used to terminate the container , It is equivalent to sending a message to the main process in the container SIGTERM The signal , Then send it again after a period of time SIGKILL The signal . bash container stop [containerID]

What is the difference between the two signals , App received SIGTERM After the signal , You can finish cleaning by yourself , But you can ignore the signal . If you receive SIGKILL Number , Will be forcibly terminated immediately , All operations in progress will be lost .

3.docker container logs

docker container logs Commands are used to view docker Output of container , Inside the container Shell Standard output of . If docker run When the command runs the container , Not used -it Parameters , Use this command to view the output . docker container logs [containerID]

4.docker container exec

docker container exec Command to enter a running docker Containers . If docker run When the command runs the container , Not used -it Parameters , Use this command to enter the container . Once inside the container, it can be placed in the Shell The order was executed . docker container exec -it [containerID] /bin/bash

5.docker container cp

docker container cp The command is used to retrieve data from a running Docker Inside the container , Copy files to this computer . The following is how to copy to the current directory . docker container cp [containID]:[/path/to/file] .

copyright:author[Chen Bucheng I],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/20210702150333875C.html