Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

docker常用命令[0]

Posted on 2023年11月14日 by

这些命令总是记不住,或者说不用心去记,所以记录在本文中,以便将来查询。

容器的操作

  • 列出所有的容器 ID
docker ps -aq
  • 停止所有的容器
docker stop $(docker ps -aq)
  • 删除所有的容器
docker rm $(docker ps -aq)
  • 复制文件
docker cp mycontainer:/opt/file.txt /opt/local/
docker cp /opt/local/file.txt mycontainer:/opt/
  • 查看当前生成的容器id
docker ps -a
  • 进入docker 容器后台运行
docker exec -it  3ikdu293  /bin/bash
  • 退出某个容器
exit
  • 启动容器
docker start 8cfd1216226e
  • 进入容器
docker attach 602237bcc6d6 #如果从这个容器退出,会导致容器的停止
  • 清理掉所有处于终止状态的容器
docker container prune
  • 查询日志
docker logs 970dc67458f6
  • 查询docker底层信息
docker inspect 970dc67458f6
  • 设置网络
docker run -d --name webapp-test -p 5000:5000 training/webapp
  • 映射到指定地址的指定端口
docker run -d --name webapp-test -p 127.0.0.1:5000:5000 training/webapp
  • 查询信息
docker ps

镜像的操作

docker images
  • 拉取镜像
docker pull centos:centos7
  • 删除所有的镜像
docker rmi $(docker images -q)

参考资料:

  1. https://colobu.com/2018/05/15/Stop-and-remove-all-docker-containers-and-images/
  2. https://www.jianshu.com/p/c6dafde9c181
  3. https://cloud.tencent.com/developer/article/1667555

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT