Answers: <p>Wouldn't this be better using docker build? Not docker compose? I'm pretty sure compose is used to spin up things together, rather than your use case. In which case, yes build supports many tags</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-07-17T10:55:05.713Z
Answers: In the sake of brevity I didn't mention that there is a rabbitmq container inside the docker-compose
Answers: Shahar Shokrani
Answers: CC BY-SA 4.0
Answers: 2022-07-18T11:02:45.577Z
Answers: But you won't be pushing that, you'll only still be pushing *your* image.
Answers: Stuart.Sklinar
Answers: CC BY-SA 4.0
Answers: 2022-07-21T18:25:16.817Z
Answers: Thank you for your help, I'll switch to docker build instead of compose.
Answers: Shahar Shokrani
Answers: CC BY-SA 4.0
Answers: 2022-07-17T10:50:14.357Z
Answers: 2022-07-17T10:50:14.357Z
Answers: Stuart.Sklinar
Body: <p>While creating a CI/CD via Azure Devops, my goal is to push two tags to the artifactory:</p>
  <ol>
  <li>latest</li>
  <li>build version (For example 1.0.X)</li>
  </ol>
  <p>My docker-compose looks like:</p>
  <pre><code>version: '3.4'
  
  services:
      mycontainer:
          image: ${Image}:${Tag}
          build:
              context: .
              dockerfile: */Dockerfile
      rabbitmq:
          ...
  </code></pre>
  <p>The yml related steps are:</p>
  <pre><code>variables:
  - name: Tag
    value: '1.0.1'
  - name: 'Image'
    value: 'myartifactory/myrepo/mycontainer'
  
  - task: DockerCompose@0
    displayName: 'Docker-Compose up data source'
    inputs:
      dockerComposeFile: 'docker-compose.yml'
      dockerComposeFileArgs: |
        Image=$(Image)
        Tag=$(Tag)
      action: 'Run a Docker Compose command'
      dockerComposeCommand: 'up --build -d'
  </code></pre>
  <p>This step successfully creates this result and I'm able to successfully push the 1.0.1's tag to artifactory:</p>
  <pre><code>Successfully built ############
  Successfully tagged myartifactory/myrepo/myproject:1.0.1 
  
  - task: ArtifactoryDocker@1
    displayName: 'Push tagged image to artifactory'
    inputs:
      command: 'push'
      artifactoryService: '...'
      targetRepo: '...'
      imageName: '$(DockerImage):$(Tag)'
  </code></pre>
  <p>Now, to push the <code>latest</code> I need to copy paste these two steps again:</p>
  <pre><code>- task: DockerCompose@0
    displayName: 'Docker-Compose up data source'
    inputs:
      dockerComposeFile: 'docker-compose.yml'
      dockerComposeFileArgs: |
        Image=$(Image)
        Tag=latest
      action: 'Run a Docker Compose command'
      dockerComposeCommand: 'up --build -d'
  
  - task: ArtifactoryDocker@1
    displayName: 'Push tagged image to artifactory'
    inputs:
      command: 'push'
      artifactoryService: '...'
      targetRepo: '...'
      imageName: '$(DockerImage):latest'
  </code></pre>
  <p>Is it possible to tag the <code>latest</code> tag together with the <code>1.0.1</code> tag and push them together?
  Because docker-compose up the project with latest again takes a lot of time.</p>
  <p>I'm trying also to avoid using script step to run <code>docker tag ...</code> to re-tag the image.</p>
  
Tags: <docker><docker-compose><azure-devops><continuous-deployment>
Title: Is it possible to create multiple tags out from docker-compose?
UserDisplayName: Shahar Shokrani
ThreadText: # Is it possible to create multiple tags out from docker-compose?
  
  (Asked by: username_0 on 2022-07-17)
  
  While creating a CI/CD via Azure Devops, my goal is to push two tags to the artifactory:
  
  1. latest
  2. build version (For example 1.0.X)
  
  My docker-compose looks like:
  
  ```
  version: '3.4'
  
  services:
      mycontainer:
          image: ${Image}:${Tag}
          build:
              context: .
              dockerfile: */Dockerfile
      rabbitmq:
          ...
  
  ```
  
  The yml related steps are:
  
  ```
  variables:
  - name: Tag
    value: '1.0.1'
  - name: 'Image'
    value: 'myartifactory/myrepo/mycontainer'
  
  - task: DockerCompose@0
    displayName: 'Docker-Compose up data source'
    inputs:
      dockerComposeFile: 'docker-compose.yml'
      dockerComposeFileArgs: |
        Image=$(Image)
        Tag=$(Tag)
      action: 'Run a Docker Compose command'
      dockerComposeCommand: 'up --build -d'
  
  ```
  
  This step successfully creates this result and I'm able to successfully push the 1.0.1's tag to artifactory:
  
  ```
  Successfully built ############
  Successfully tagged myartifactory/myrepo/myproject:1.0.1 
  
  - task: ArtifactoryDocker@1
    displayName: 'Push tagged image to artifactory'
    inputs:
      command: 'push'
      artifactoryService: '...'
      targetRepo: '...'
      imageName: '$(DockerImage):$(Tag)'
  
  ```
  
  Now, to push the `latest` I need to copy paste these two steps again:
  
  ```
  - task: DockerCompose@0
    displayName: 'Docker-Compose up data source'
    inputs:
      dockerComposeFile: 'docker-compose.yml'
      dockerComposeFileArgs: |
        Image=$(Image)
        Tag=latest
      action: 'Run a Docker Compose command'
      dockerComposeCommand: 'up --build -d'
  
  - task: ArtifactoryDocker@1
    displayName: 'Push tagged image to artifactory'
    inputs:
      command: 'push'
      artifactoryService: '...'
      targetRepo: '...'
      imageName: '$(DockerImage):latest'
  
  ```
  
  Is it possible to tag the `latest` tag together with the `1.0.1` tag and push them together?
  Because docker-compose up the project with latest again takes a lot of time.
  
  I'm trying also to avoid using script step to run `docker tag ...` to re-tag the image.
  
  **Tags:** docker, docker-compose, azure-devops, continuous-deployment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-17. Score: 1 | Accepted answer
  
  Wouldn't this be better using docker build? Not docker compose? I'm pretty sure compose is used to spin up things together, rather than your use case. In which case, yes build supports many tags
  
  > **Comments:**
  > **username_0**: In the sake of brevity I didn't mention that there is a rabbitmq container inside the docker-compose  
  > **username_1**: But you won't be pushing that, you'll only still be pushing *your* image.  
  > **username_0**: Thank you for your help, I'll switch to docker build instead of compose.  
  
  ---
  
  