如果图像是使用 "build" 属性构建的,如何指定图像版本

How to specify the image version if image is built using "build" attribute

如果 Dockerfile 作为文件夹 foo 的一部分可用并且我们使用构建选项在 docker-compose.yaml 文件中构建它,如何指定图像版本。否则它会说“最新”,但我们想指定类似 0.0.1

的内容
  foo-gateway:
    container_name: "foo-gateway"
    build: foo
    ports:
      - 9000:80
      - 9090:8080

foo/dockerfile

您可以提供图片名称:

  foo-gateway:
    container_name: "foo-gateway"
    image: foo:0.0.1
    build: foo
    ports:
      - 9000:80
      - 9090:8080