当前位置: 首页 > news >正文

docker命令行的使用

在Docker Hub上查询镜像:

pi@pi-NMH-WCX9:~$ docker search hello-world

在Docker Hub上拉取镜像:

pi@pi-NMH-WCX9:~$ docker pull hello-world

查看容器列表:

pi@pi-NMH-WCX9:~$ docker ps -a
CONTAINER ID   IMAGE                     COMMAND                  CREATED        STATUS       PORTS                                                 NAMES
8a024dac6f5d   hexo_ubuntu22.04:latest   "/usr/local/bin/hexo…"   3 days ago     Up 3 hours   22/tcp, 0.0.0.0:8123->4000/tcp, [::]:8123->4000/tcp   hexo-server
c8d2b2520c00   8a3cdc4d1ad3              "/bin/bash"              3 months ago   Up 3 hours   127.0.0.1:8122->22/tcp                                loving_hertz

查看镜像列表:

# Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]
pi@pi-NMH-WCX9:~$ docker images
REPOSITORY           TAG       IMAGE ID       CREATED         SIZE
hexo_ubuntu22.04     latest    261dea374744   3 days ago      1.11GB
docker_ubuntu22-04   latest    2a0823f51114   3 months ago    3.42GB
ubuntu               22.04     8a3cdc4d1ad3   6 months ago    77.9MB
ubuntu               20.04     5f5250218d28   6 months ago    72.8MB
hello-world          latest    d2c94e258dcb   20 months ago   13.3kB

创建&运行容器:

# Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
# 注意:IMAGE 即可以是 IMAGE_ID,也可以是 REPOSITORY:TAG , 或 REPOSITORY 
pi@pi-NMH-WCX9:~$ docker run hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/

在运行容器执行命令:

# Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
#Execute a command in a running container
#
#Aliases:
#  docker container exec, docker exec
#
#Options:
#  -d, --detach               Detached mode: run command in the background
#      --detach-keys string   Override the key sequence for detaching a container
#  -e, --env list             Set environment variables
#      --env-file list        Read in a file of environment variables
#  -i, --interactive          Keep STDIN open even if not attached
#      --privileged           Give extended privileges to the command
#  -t, --tty                  Allocate a pseudo-TTY
#  -u, --user string          Username or UID (format: "<name|uid>[:<group|gid>]")
#  -w, --workdir string       Working directory inside the container

删除容器:

# Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]
# 注意:CONTAINER 即容器ID,一般前4位数就可以代表一个容器
pi@pi-NMH-WCX9:~$ docker rm d3e2
d3e2

删除镜像:

# Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]
pi@pi-NMH-WCX9:~$ docker rm d2c9
d2c9
http://www.zskr.cn/news/137579.html

相关文章:

  • Blender到Unreal Engine 3D资产迁移全攻略:从建模小白到游戏开发高手
  • Chrome网页文本替换插件:从基础到精通的完全实战指南
  • 2025医学考研课程TOP10大揭秘,你想知道的都在这! - 品牌测评鉴赏家
  • 计算机Java毕设实战-基于springboot的电动车租赁平台系统设计与实现【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 深度启动盘制作终极指南:完全掌握Deepin Boot Maker使用技巧
  • 小爱音箱音乐解锁终极教程:5分钟告别版权限制实现全平台音乐播放
  • BetterNCM安装器:解锁网易云音乐隐藏潜能的终极钥匙
  • P13275 [NOI2025] 集合
  • 5分钟掌握Obsidian代码块美化终极技巧
  • 2025年国内智能营销服务商权威推荐排行榜——聚焦AI搜索推广驱动与全域增长,助力企业精准决策 - 呼呼拉呼
  • QMC解码器完整指南:快速解锁QQ音乐加密音频的终极方案
  • 5个常见问题解析:为什么容器音乐服务找不到你的本地歌曲
  • 从源码角度解析C++20新特性如何简化线程超时取消
  • OpenRPA:免费开源的企业级自动化平台完整指南
  • ESP32引脚资源分配建议:合理规划I/O口方案
  • 消费品转型品牌战略咨询怎么做?奇正沐古品牌分析 - 资讯焦点
  • 2025年国内地坪源头厂商权威推荐排行榜——聚焦企业服务与产品性能,助力精准选型(涵盖固化剂/水性聚氨酯砂浆/环氧/聚氨酯超耐磨地坪工程厂商) - 呼呼拉呼
  • Playwright MCP浏览器自动化指南:让AI精准理解你的命令 - 教程
  • 2025年AI培训老师怎么选?这5位实战派专家帮你突破技术瓶颈 - 品牌测评鉴赏家
  • PlantAssistant-轻松浏览1G的RVM
  • 波特律动串口助手:浏览器端串口调试终极指南
  • 2025专家视角:国内专业地坪材料与工程厂家解决方案综合评估与推荐 - 呼呼拉呼
  • Zeppelin - Connect to Flink SQL Gateway
  • 计算机Java毕设实战-基于springboot的可追溯果园生产过程管理系统的设计与实现 “种植 - 管理 - 采收 - 溯源” 全链条数字化体【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • 常见的http返回headers
  • BetterNCM安装器:一键解锁网易云音乐无限潜能
  • 信息素养大赛 2025 游记
  • 3分钟掌握Sketchfab模型下载:免费工具完全攻略
  • Vue 3样式深度选择器:为什么我们需要:deep()? - 教程
  • OpenCore Legacy Patcher:让旧Mac焕发新生的完整指南