docker常用命令

常用命令,英文见谅

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!!!

命令总结图

docker命令总结

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值