如何使用docker-compose标记docker映像 [英] How to tag docker image with docker-compose

查看:73
本文介绍了如何使用docker-compose标记docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过docker-compose构建映像并为其设置特定标签。 文档说:

I want to build image via docker-compose and set specific tag to it. Documentation says:


Compose将使用生成的名称来构建并标记它,然后使用该
图像。

Compose will build and tag it with a generated name, and use that image thereafter.

但是我无法找到指定标签的方法,对于生成的图像,我总是看到最新标签。

But I can't find a way to specify tag and for built images I always see 'latest' tag.

推荐答案

似乎文档/ tool已更新,您现在可以在脚本中添加 image 标记。这对我来说是成功的。

It seems the docs/tool have been updated and you can now add the image tag to your script. This was successful for me.

示例:

version: '2'
services:

  baggins.api.rest:
    image: my.image.name:rc2
    build:
      context: ../..
      dockerfile: app/Docker/Dockerfile.release
    ports:
      ...

https://docs.docker.com/compose/compose-file/#build

这篇关于如何使用docker-compose标记docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆