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.


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")
    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
    sh("docker-compose down -v")
    sh("docker network prune -f")


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

      name: aa_backend_network
  • 2
    You should probably remove passwords from your question.. – MrDuk Mar 30 '18 at 18:40

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.)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.