由于工作需要,今天测试了一下 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