How to tag docker image with docker-compose

后端 未结 4 1814
清歌不尽
清歌不尽 2020-12-04 11:42

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

Compose will build and tag it with a generated name, and use

相关标签:
4条回答
  • 2020-12-04 12:13

    Original answer Nov 20 '15:

    No option for a specific tag as of Today. Docker compose just does its magic and assigns a tag like you are seeing. You can always have some script call docker tag <image> <tag> after you call docker-compose.

    Now there's an option as described above or here

    build: ./dir
    image: webapp:tag
    
    0 讨论(0)
  • 2020-12-04 12:15

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

    Example:

    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

    0 讨论(0)
  • 2020-12-04 12:26

    If you specify image as well as build, then Compose names the built image with the webapp and optional tag specified in image:

    build: ./dir
    image: webapp:tag
    

    This results in an image named webapp and tagged tag, built from ./dir.

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

    0 讨论(0)
  • 2020-12-04 12:34

    you can try:

    services:
      nameis:
        container_name: hi_my
        build: .
        image: hi_my_nameis:v1.0.0
    
    
    0 讨论(0)
提交回复
热议问题