标记 docker-compose 中使用的 postgres 图像?

tag postgres image used in docker-compose?

我有以下 docker-compose 文件:

version: "3.7"

services:
  bejebeje-identity:
    build:
      context: ./Bejebeje.Identity
      labels:
        com.bejebeje.description: "Bejebeje's Identity Server"
    image: bejebeje/identity:latest
    ports:
      - "5006:443"
      - "5005:80"
    env_file:
      - ./variables.env
    depends_on:
      - database
    volumes:
      - ~/.aspnet/https:/root/.aspnet/https/
  database:
    image: postgres:13.0
    ports:
      - "8001:5432"
    volumes:
      - data-volume:/var/lib/postgresql/data
    env_file:
      - ./variables.env

volumes:
  data-volume:

当我 运行 docker-compose build . 构建图像时,我然后 运行 docker image ls 我得到:

我怀疑<none>图像是postgres数据库?在我的 docker-compose 文件中,如何使用 database/bejebeje/identity?

之类的标记数据库图像

'none' 不是 postgres 图像,但与 bejebeje-identit 相关,仅由 docker 文件引导。

docker 中有多阶段构建模式。它将创建多阶段 docker 图像。 您可以在项目 docker 文件中找到以下行。

# copy the contents of /app/out in the `build-env` and paste it in the
# `/app` directory of the new runtime container.
COPY --from=build-env /app/out .

这就是原因。 只需重写您的 docker 文件,并删除之前的舞台图像。然后你将不会再看到 'non' 标记的图像。