<p>Just make sure the images you build all have the right names in terms of registry prefix and so on. If not you need to rename them accordingly.</p>

<p>Otherwise this task is pretty easy. To push all Images you build using a docker-compose file just use <code>docker-compose push</code>.</p>

<p>Make sure you are authorised to push to the registry (logged in etc.)</p>

CC BY-SA 3.0
2018-03-31T09:39:21.317Z
2018-03-31T09:39:21.317Z
Marvin Winkler
<p>I am using Jenkins pipeline and run a shell command to bring up my linked containers for testing. Once the testing is complete, I want to push the containers to a registry (I would prefer AWS ERC, but at this point I will take any working examples). What is the proper way to do this? Should each image go to a different repository? How can I get all of the containers created by the compose file pushed up? I have been attempting to get this done with the docker-compose push command, but I can't seem to get it working properly or find any decent examples. </p>

<p>Jenkinsfile</p>

<pre><code>node('ec2-build-slave') {
    stage('Docker Build') {
        /* This builds the actual image; synonymous to
        * docker build on the command line */

        sh("docker network create aa_backend_network")
        sh("docker-compose up -d --build")
        //docker.build("$IMAGE")
    }
    stage ('Docker Push'){
        // /* This pushes the previously built image to the Amazon
        // * ECS Container Registry */
        sh("eval \$(aws ecr get-login --region us-west-2 --no-include-email | sed 's|https://||')")
        // docker.withRegistry(ECR_URL, ECR_CRED) {
        // docker.image(IMAGE).push()
        // }


        sh("docker-compose build")
        sh("docker-compose push")
    }
}
catch (exc) {
    currentBuild.result = "FAILED"
    throw exc
}
finally {
    // Success or failure, always send notifications
    notifyBuild(currentBuild.result)
    sh("docker-compose down -v")
    sh("docker network prune -f")
}
}
}
</code></pre>

<p>docker-compose</p>

<pre><code>version: "2"
services:
  db_setup:
    networks:
      - default
    build: .
    depends_on:
      - db
    container_name: db_setup
    image: db_setup
    command: python asteri_analytics_db.py
    working_dir: /asteri_analytics_db/asteri_analytics_db
  db:
    networks:
      - default
      - outside
    image: mongo:3.6.3
    container_name: mongo_db
    restart: always
    environment:
      MONGO_DATA_DIR: /data/db
      MONGO_LOG_DIR: /dev/null
      MONGO_INITDB_ROOT_USERNAME: ###edited####
      MONGO_INITDB_ROOT_PASSWORD: ###edited####
    ports:
      - 27017:27017

networks:
  outside:
    external:
      name: aa_backend_network
</code></pre>

CC BY-SA 3.0
2018-03-30T18:40:12.177Z
You should probably remove passwords from your question..
MrDuk
<docker><jenkins><jenkins-pipeline><docker-compose><amazon-ecs>
How can I push multiple containers, created with docker-compose, to a registry
Rick james
# How can I push multiple containers, created with docker-compose, to a registry

(Asked by: username_0 on 2018-03-30)

I am using Jenkins pipeline and run a shell command to bring up my linked containers for testing. Once the testing is complete, I want to push the containers to a registry (I would prefer AWS ERC, but at this point I will take any working examples). What is the proper way to do this? Should each image go to a different repository? How can I get all of the containers created by the compose file pushed up? I have been attempting to get this done with the docker-compose push command, but I can't seem to get it working properly or find any decent examples. 
Jenkinsfile
node('ec2-build-slave') {
    stage('Docker Build') {
        /* This builds the actual image; synonymous to
        * docker build on the command line */

        sh("docker network create aa_backend_network")
        sh("docker-compose up -d --build")
        //docker.build("$IMAGE")
    }
    stage ('Docker Push'){
        // /* This pushes the previously built image to the Amazon
        // * ECS Container Registry */
        sh("eval \$(aws ecr get-login --region us-west-2 --no-include-email | sed 's|https://||')")
        // docker.withRegistry(ECR_URL, ECR_CRED) {
        // docker.image(IMAGE).push()
        // }


        sh("docker-compose build")
        sh("docker-compose push")
    }
}
catch (exc) {
    currentBuild.result = "FAILED"
    throw exc
}
finally {
    // Success or failure, always send notifications
    notifyBuild(currentBuild.result)
    sh("docker-compose down -v")
    sh("docker network prune -f")
}
}
}

docker-compose
version: "2"
services:
  db_setup:
    networks:
      - default
    build: .
    depends_on:
      - db
    container_name: db_setup
    image: db_setup
    command: python asteri_analytics_db.py
    working_dir: /asteri_analytics_db/asteri_analytics_db
  db:
    networks:
      - default
      - outside
    image: mongo:3.6.3
    container_name: mongo_db
    restart: always
    environment:
      MONGO_DATA_DIR: /data/db
      MONGO_LOG_DIR: /dev/null
      MONGO_INITDB_ROOT_USERNAME: ###edited####
      MONGO_INITDB_ROOT_PASSWORD: ###edited####
    ports:
      - 27017:27017

networks:
  outside:
    external:
      name: aa_backend_network

**Tags:** docker, jenkins, jenkins-pipeline, docker-compose, amazon-ecs

> **Comments:**
> **username_1**: You should probably remove passwords from your question..  

---

## 1 answers

### Answer by username_2 on 2018-03-31. Score: 3

Just make sure the images you build all have the right names in terms of registry prefix and so on. If not you need to rename them accordingly.

Otherwise this task is pretty easy. To push all Images you build using a docker-compose file just use `docker-compose push`.

Make sure you are authorised to push to the registry (logged in etc.)


---

