首页 > 解决方案 > 在 docker-compose 中使用标记 postgres 图像?

问题描述

我有以下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并得到:

泊坞窗图像 ls

我怀疑<none>图像是 postgres 数据库?在我的docker-compose文件中,我怎样才能用类似的东西标记数据库图像database/bejebeje/identity

标签: postgresqldockerdocker-composetags

解决方案


“无”不是 postgres 图像,而是与 bejebeje-identit 相关,并且仅由 dockerfile 领导。

docker中有多阶段构建模式。它将创建多阶段泊坞窗图像。您可以从项目 dockerfile 中找到以下行。

# 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 .

这就是原因。只需重写您的 dockerfile,并删除前一个阶段的图像。然后您将不会再看到“非”标记的图像。


推荐阅读