table of Contents
Reference: "Docker ---- from entry to practice."
docker run
Create a container, and execute application code, if no local image file, the server will start to pull the image file.
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
E.g:
docker run -d -p 80:80 --name webserver nginx
- -d parameter represents the background daemon running container
- --name parameter indicates the name of the vessel, free to take
- -v shows a map and a host container to share files, directories container is Dockerfile VOLUME command with defined directory (mount directory)
- Table -p port and host port mapping container, the container port is used EXPOSE command binding Dockerfile
- Specifies a dummy terminal or terminals in the new container and then -t
- -i allows you to standard input (STDIN) in the container to interact
- -it start an interactive terminal
- -runtime runtime use for this container
- --rm exit the container Clear data
docker ps
View container running
docker exec
Login container, without creating a new container line if we want to enter commands running in the background of the container, simply enter the following example
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
example:docker exec -it ecef8319d2c8 /bin/sh
- -d: Split mode: running in the background
- -i: Even without additional remains open STDIN
- -t: assign a pseudo-terminal
docker cp
Upload: current operating system to copy files to the vessel
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
examples:docker cp /root/test.txt ecef8319d2c8:/root/
- -L: maintain the link source targets
Download: Copy the file container to the operating system the current
docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
example:docker cp ecef8319d2c8:/root/test.txt /root/
import hello
docker stop
docker stop $ CONTAINER_ID terminate a running container
docker images
View downloaded image
docker pull
A mirrored pull