栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

docker常用命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

命令总结图

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/882284.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号