Skip to content

操作镜像

查看镜像

shell
docker images

拉取镜像

shell
docker pull imageName

上述命令默认拉取镜像的最新版本,即 latest。

如需拉取指定版本,可在镜像名后面添加版本号

shell
docker pull imageName:tag

example

拉取 node 最新镜像

shell
docker pull node

拉取 node18-alpine 镜像

shell
docker pull node:18-alpine

构建镜像

shell
docker build -t imageName -f DockerfilePath PATH
  • -t:指定镜像名字

  • -f:指定Dockerfile的路径

  • PATH:指定一个目录路径,表示 docker build 构建的环境目录

example

:::vue

|—— nginx

| |—— nginx.conf

|—— public

| |—— index.html

|—— app.js

|—— Dockerfile

:::

shell
docker build -t nodeImage -f ./Dockerfile .

删除镜像

shell
docker rmi imageName:tag