当前位置: 首页 > 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.jsqmd.com/news/125175/

相关文章:

  • 容器化部署中的目录挂载问题排查与修复指南
  • 苍穹外卖复习
  • 2025.12.22 - 呓语
  • 快速提取碧蓝航线Live2D模型:新手3分钟入门指南
  • Blender到Unreal Engine 3D资产迁移全攻略:从建模小白到游戏开发高手
  • Chrome网页文本替换插件:从基础到精通的完全实战指南
  • 2025.12.21 模拟赛
  • 2025医学考研课程TOP10大揭秘,你想知道的都在这! - 品牌测评鉴赏家
  • yolov8常见参数
  • 计算机Java毕设实战-基于springboot的电动车租赁平台系统设计与实现【完整源码+LW+部署说明+演示视频,全bao一条龙等】
  • Deepin Boot Maker 终极指南:一键制作Linux启动盘的完整教程
  • 串口助手完整使用教程:从零基础到高效调试
  • 手把手教你安装Synaptics触控板驱动程序
  • Python在分布式日志聚合与实时分析优秀的平台中高并发处理与可视化实践
  • APK Editor Studio完全指南:从安装到精通Android应用编辑
  • 5步掌握APK Editor Studio:安卓应用编辑终极指南
  • 2026年医学考研党必看!优质课程大揭秘 - 品牌测评鉴赏家
  • 深度启动盘制作终极指南:完全掌握Deepin Boot Maker使用技巧
  • qmc-decoder:彻底解决音频格式受限的专业解码方案
  • 国内AI推广排名优化公司哪家好?2025年年终5家头部厂商深度对比及推荐。 - 呼呼拉呼
  • 彻底解决xiaomusic本地音乐扫描失败:终极排查指南
  • 小爱音箱音乐解锁终极教程:5分钟告别版权限制实现全平台音乐播放
  • BetterNCM插件管理器:从零开始的完整使用指南
  • BetterNCM安装器:解锁网易云音乐隐藏潜能的终极钥匙
  • P13275 [NOI2025] 集合
  • 5分钟掌握Obsidian代码块美化终极技巧
  • BetterNCM终极安装指南:轻松解锁网易云音乐隐藏功能
  • 告别插件安装烦恼:BetterNCM智能管理工具全解析
  • 医学考研党必看!2025靠谱机构测评指南,这几家闭眼入不踩坑 - 品牌测评鉴赏家
  • OpenRPA:免费开源的企业级自动化平台完整指南