Cloud computing docker container using the command

docker use the command:

See docker docker version Version
 VI   / etc / docker / daemon.json 
{ 
   " Registry-Mirrors " : [ " https://registry.docker-cn.com " ] 
} acceleration mirror configuration docker   

docker RUN -d -p 80 : 80 nginx start a container 
run (create and launch a vessel)
 - d in the background
 - the p-port mapping 
nginx docker image name 
docker image management commands:
docker Search XXXX Search the default search mirroring the official website hub.docker.com this is the official repository address Docker pull (the Push) CentOS:
6.9 does not specify the default version will download the latest version Docker pull doacloud.io / huangzhichong / alpine- CN: latest this is downloaded from a private warehouse docker images to view mirror list Examples RMI docker: docker Image RM CentOS: Latest delete image save Examples docker: docker Image save CentOS . -o docker_centos7 . 4 . the tar .gz image derived docker Examples Load: Load Image docker . docker_centos7 -i . 4 . the tar .gz introduced mirror
docker container management:
Docker rUN -d -p 80:80 nginx: Latest
rUN (create and run a container)
-d in the background
-p port mapping
nginx docker image name
docker run -it --name centos6 centos: 6.9 / bin / bash
terminal -it allocation interactive
name --name specified container
/ bin / bash covered container initial command
docker run xxx run container
docker start xxx launch container
docker stop xxx stop the container
docker kill xxx killed container
docker ps (-a -l -q) to view the list of containers
*** into the container is recommended as follows
docker exec (will assign a new terminal TTY)
Docker Exec -it container vessel name or id / bin / bash (/ bin / SH)
Docker the attach (using the same terminal) can use this operation to view another container engineers secretly left the p-shortcut keys + CTEL, Ctrl + q
Docker RM xxx delete container
docker rm -f `docker ps -a -q` entire batch delete container
******* summary: the first process (initial order) in the docker container must always be in a state of running in the foreground (ram must live), otherwise the container will be signed out
business operations in the container: The initial order, tamping live, start the service

 Network Access docker container (port mapping):
docker0: 172.17.0.1 jumpserver: 172.17.0.2 nginx: 172.17.0.3
specify the mapping (docker will automatically add an iptables rules to achieve port mapping)
-p hostPort: containerPort
-p ip : hostPort: containerPort wants to use a plurality of containers 8080
-p ip :: containerPort (random port)
-p hostPort: containerPort / UDP
-p 10.0.0.100::53/udp use this host to 10.0.0.100 udp ip address protocol mapping random container port udp53 port
-p 81:80 -p 443: 443 can specify multiple -p
random mapping
docker run -P (random port)
implemented by iptables port mapping
example: docker run -d -p 80:80 nginx -p host port: the virtual machine a plurality of ports can be added in one parameter specifies -p
example: RUN Docker -p -d -p 80:80 443: 443 Nginx
Docker RUN -P (random port) large P

docker data volume management:

/ usr / report this content share / nginx / HTML 
-v / opt / xiaoniao: / usr / report this content share / nginx / HTML
persistent
data volumes (file or directory)
-v volume name: / data (first roll is empty, the container will copied to the volume data, if there are data volume, the data volume mounted to the vessel)
-v the src (host directory): dst (directory container)
data volume container
-volumes-from (with certain existing container mount the same volume) based on nginx start a container, monitor 80 and 81, access 80, nginx appears to welcome the default home page, access 81, appeared birds. -p 80:80 -p 81:81 -v xxx: xxx -v xxx: xxxx -based multi-site nginx. example:





docker run -d -p 80:80 -p 81:81 -v /opt/xiaoniao:/usr/share/nginx/html nginx:latest

Guess you like

Origin www.cnblogs.com/oldsjf/p/11761429.html