Skip to content

基本用法

查看命令

docker

查看版本,简要和详细。

docker -v

docker version

快速开始

docker run hello-world

Docker 先检查本地镜像,如果没有,再默认去 Docker Hub 拉取镜像。拉取成功后,基于镜像制作容器,运行容器。

分两步

docker pull hello-world

docker run hello-world

运行容器,指定容器名称 test ,不使用随机名称,端口映射 80:80 ,后台运行。

docker run --name test -p 80:80 -d nginx

访问 http://localhost

查看镜像,列出仓库、标签、镜像 ID、创建时间、大小。

docker images

查看运行中的容器,列出容器 ID、镜像、命令、创建时间、状态、端口、名称。

docker ps

查看所有容器

docker ps -a

联系 math@baima.site