Docker usage finishing

Docker tutorial recommended

Two good references:
https://yeasy.gitbooks.io/docker_practice/content/introduction/
https://www.cnblogs.com/bethal/p/5942369.html


Mirror:

View Mirror

docker images ls

Remove Mirror

docker image rm <image id>

Mirror Pull

docker pull [image name]
e.g. docker pull tensorflow / serving: 1.14.0- gpu (gpu version tf-serving)

Find Mirror

The official image library docker_hub: https://hub.docker.com/
CUDA related mirror: https: //hub.docker.com/r/nvidia/cuda/

Mirror building

Construction using Dockerfile mirror
docker build -t [image_name: tag] [ Context Path]
For example: docker build -t antispam / server: . Test1
constructed image by the operation of the container (not recommended)
Docker the commit -m "Message" -a " author "[CONTAINER ID] [naming a new image]


container:

View all run container

docker container ls
docker container ps | grep “tensorflow/serving”

View all containers

docker container ls -a

Termination of the specified container

docker container kill [container id]

Removes the specified container

docker container rm trusting_newton

Delete all containers in the termination state

docker container prune

Running a temporary container, automatically terminate after use

RUN Expediting IT --rm Image Docker: Tag / bin / the bash
Expediting IT equivalent to setting up a pseudo-terminal and can interact with the container interior, to facilitate debugging and used
when the inner container, the exit command or the Ctrl + d exit
use - rm parameters to ensure automatic termination of the current container exit, usually in the temporary debugging will be so used

A container background

Use the -d parameter setting the background container
docker run -d image: tag
container whether the long run, and in order docker run or Dockerfile CMD designated to perform related and unrelated -d parameter.
If you want to run a long mirror does not specify any command, you can use the following command:
Docker RUN -dit Image: Tag
using the -p parameter configuration port mapping, so that an externally accessible container
docker run -it --rm -p port: port image : Tag / bin / bash
Docker RUN -d -p Port: Port Image: Tag
use --mount for file / directory is mounted, you must set an absolute path
-mount type = bind, source = / src / webapp, target = / opt / webapp

Use the exec command into the container of a running

docker exec -it container_id bash

Data copy

External data copied into the container
/ dst_path_in_container: docker cp / src_path container_id
copy of the data to an external container
docker cp container_id: / src_path_in_container / dst_path
Example: docker cp 4b3f8de49dff: /usr/local/tomcat/logs/catalina.out / opt /

Published 87 original articles · won praise 325 · views 520 000 +

Guess you like

Origin blog.csdn.net/u011583927/article/details/104094323