Docker 常用命令

由于工作需要,今天测试了一下 Docker,发现确实挺好用的。所以记录一下 Docker 相关的命令。
个人目前使用 Win10 + WSL2。

Docker System requirements

我现在的是 Docker Desktop on Windows。

WSL2 backend

  • Windows 10 64-bit: Home, Pro, Enterprise, or Education, version 1903 (Build 18362 or higher).
  • Enable the WSL 2 feature on Windows.
  • The following hardware prerequisites are required to successfully run WSL 2 on Windows 10:
    • 64-bit processor with Second Level Address Translation (SLAT)
    • 4GB system RAM
    • BIOS-level hardware virtualization support must be enabled in the BIOS settings. For more information, see Virtualization.
      以上来自 https://docs.docker.com/docker-for-windows/install/。说白了,就是需要 Win10 使能 WSL2。

Docker 常用命令

注意:以下命令都需要 Docker 安装完成后。

编译镜像文件

使用命令 docker build。这个命令还在进一步研究中。

运行镜像文件

使用命令 docker run。这个命令还在进一步研究中。
注意:要有了镜像文件后,才能 run。

查看镜像进程

使用命令 docker ps -a。如下所示。

C:\Users\Mathlab>docker ps -a
CONTAINER ID   IMAGE        COMMAND       CREATED          STATUS                      PORTS     NAM
ES
957cb88e18e7   afepack:v0   "/bin/bash"   3 minutes ago    Exited (1) 2 minutes ago              jov
ial_knuth
cf420d20e741   afepack:v0   "/bin/bash"   56 minutes ago   Exited (0) 49 minutes ago             unr
uffled_shamir

停止镜像进程

使用 docker stop ,其中 CONTAINER ID 为 ps 中的 ID。例如上面,

C:\Users\Mathlab>docker stop 957cb88e18e7

卸载镜像

使用 docker rm ,其中 CONTAINER ID 为 ps 中的 ID。例如上面,

C:\Users\Mathlab>docker rm 957cb88e18e7
957cb88e18e7

查看镜像

使用命令 docker images。如下所示。

C:\Users\Mathlab>docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
afepack      v0        a5b6d2e6709d   57 minutes ago   908MB

删除镜像

使用命令 docker rmi ,其中 CONTAINER ID 为 ps 中的 ID。例如上面,

C:\Users\Mathlab>docker rmi a5b6d2e6709d
Untagged: afepack:v0
Deleted: sha256:a5b6d2e6709d8ca0a2fdfc93fab69bff88392ba3e467635e31b11f5fc8d5bcc7
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

努力的老周

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值