Docker use notes - the basis of common commands

Common basic commands

Environment: Linux Ubuntu

1. Review the information docker

docker version | docker info

2. Start docker Service

sudo systemctl start docker

3. List the machine all the image files

docker image ls  | docker images

4. Delete docker image

docker image rm imageName

5. The docker caught local files from the repository

docker image pull hello-world

6. Run a document image, generates a container

docker container run hello-world

ps:

①docker container run command has automatically grab image file functions, not specified if the local image file found, it will crawl directly from the warehouse. Therefore, docker image pull is not a necessary step

②docker container run -p 8000:3000 --rm -it -v /home/dock/:/home/mount/ --name first koa-demo /bin/bash

by:

         -p container port and the local port mapping, before the colon after a local port, colon container port. Examples here are mapped to port 3000 to port 8000 of container

         --rm container file is automatically deleted after the termination of operation of the vessel

         shell -it container mapped to the current shell, then the command that you enter in the native window, will be passed to the container. 

     -v mount a local directory, a colon before host directory must be an absolute path, after the colon is mounted within the image path.

         --name name to the container, without this parameter will be randomly generated name

7. List container of the present machine is running

docker container ls

The machine lists all containers, comprising a termination vessel

docker container ls --all

8. Termination container runs

docker container kill [containerID]

Termination container operation will still take up hard disk space, you can remove

docker container rm [containerID]

9.

① termination container operation

docker container stop [containerID]

ps:

Preceding docker container killcommand to terminate operation of the vessel, with a SIGKILL signal corresponds to the inside of the container main process. The docker container stopcommand is used to terminate operation of the vessel, corresponding to the main process SIGTERM signal sent inside the container, and then over a period of time with a SIGKILL signal.

The difference between these two signals is that the application after receiving SIGTERM signal, may be ending their own clean-up work, but also can ignore this signal. If you receive a SIGKILL signal, it will be forced to immediately terminate the operation of those in progress will be lost.

② start the container, which is used to enable the container file has stopped running

docker container start [containerID]

 10 into the container

docker container exec -it [containerID]  /bin/bash

 

 

 

Guess you like

Origin www.cnblogs.com/jingying/p/12285255.html