常用命令,英文见谅
basic instruction
docker images #show all the docker images, contain Name and Image_id
docker pull [app:version] #install [app] from dockerhub , also we can point version
docker rmi -f [image_id] #remove image with [image_id] in local
run instruction
docker run [parameter] [image]
- start a [image] with [parameter]
--name = Name #container name
-d #backgroud run (must a foreground process) if it without app,then docker will kill itself
-it #callable use bash or sh terminal
- -p #port
-p host_ip host_port : container_port
-p host_port : container_port (*Main)
-p container_port
-P #(not p)random port
docker ps [para]
- list running container
-a # list running and past
-n=? #latest created container
-q #only id
exit container
exit
- stop container and exit = Ctrl + p
Ctrl + p + q
- only exit (no stop container)
remove container
docker rm [container_id] #remove pointed container
- -f #force remove (stop running container)
eg:
docker rm -f $(docker ps -aq) #*delete all the container(running or stop)
docker ps -a -q | xargs docker rm # == up
docker start [container_id] # start container
docker restart [id] # restart container
docker stop [id] # stop running container
docker kill [id] # force stop running container
docker run -d [image] #background run if it without app,then docker will kill itself
docker logs [opt]
eg:docker logs -t -f --tail [num] [container_id]
-tf #all the logs f:format
--tail [num] num of logs
docker top [id]#look the process id in container_id
docker inspect [id] # lookup the info of container
docker exec -it [container_id] bashshell
- enter container and start a new terminal
eg:docker exec -it 1cb507253b6d /bin/bash
docker attach [container_id]#enter container running terminal
docker cp [id]: /…(container) /…(host)
- copy data from docker
eg:sudo docker cp 4d683668fa88:/home/test.java /home
homework 1 nginx
docker run -d --name nginx01 -p 3344:80 nginx
#map localhost:3344 to nginx:80!!! good very good!!!