Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

847
Views
Pull Image from Gitlab Registry in Docker Compose File

I want to deploy a docker stack on my own server. I've written a .gitlab-ci.yml file that currently builds the images in my stack and pushes them to my gitlab registry:

build:
  stage: build
  image: docker:stable
  services: 
    - docker:dind
  before_script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker info
  script:
    - docker build -t $DOCKER_IMAGE1_TAG -f dir1/Dockerfile ./dir1
    - docker push $DOCKER_IMAGE1_TAG
    - docker build -t $DOCKER_IMAGE2_TAG -f dir2/Dockerfile ./dir2
    - docker push $DOCKER_IMAGE2_TAG  

I'm struggling for a way to run the docker deploy command on my own server with the docker-compose.yml file I've written, that successfully pulls the images from my gitlab registry. I figure I could use sshpass to ssh into my server and then copy the docker-compose.yml file across and run docker deploy from there, but I'm not sure what's the best way to allow my server to access the images now located in my gitlab registry:

# Need to ssh into the server, transfer over docker-stack file and run docker swarm deploy
deploy:
  stage: deploy
  environment:
    name: production
  image: trion/ng-cli-karma
  before_script:
    - apt-get update -qq && apt-get install -y -qq sshpass
    - eval $(ssh-agent -s)

This is a section of my docker-compse file:

version: "3.2"
services:
  octeditor:
    image: image # how to set this to the image in my container registry?
    ports:
      - "3000:3000"
    networks:
      - front-tier
    deploy:
      replicas: 1
      update_config:
        parallelism: 1
      failure_action: rollback
      placement:
        constraints:
          - 'node.role == manager'
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3
        window: 120s

How can I pull the images from my gitlab registry? Is this the preferred way of creating a docker deployment on a remote server, via gitlab ci?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I equally had this difficulty recently, finally I found out that the solution is just to insert the link to the image in the private registry as is the case for me with gitlab.

version: "3.2"
services:
  octeditor:
    image: registry.gitlab.com/project-or-group/project-name/image-name:tag
    ports:
      - "3000:3000"
    networks:
      - front-tier


over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!