GitLab CI: How to pull specific docker container for deployment

I’m doing the productive deploy in gitlab manually. I’m using docker container.
Clicking on the ‘Play’-Button in the pipeline list should do the deploy.
But how do I get the version of the selected container? Doing this script is always trying to pull the latest version, which should not be. I want to pull the ‘selected’ container.

deploy_prod:
  stage: deploy
  script:
    - docker pull $CI_REGISTRY_IMAGE     # here selected version is missing
    # ...
  when: manual
  environment:
    name: productive
    url: https://example.com
  only:
    - master

  • Use separate docker container for code only
  • ElasticSearch in Windows docker image vm max map coun
  • Docker container sometimes hangs and cannot be stopped
  • Docker build failing when using gcsfuse to mount google storage
  • Troubleshoot docker connectivity to external network
  • Restore Tensorflow model on docker
  • Using SSH keys inside docker container
  • Docker cpu shares and garant minimum allocated CPU for container
  • Add to container's /etc/hosts using Fig?
  • Docker (NGINX, PHP, mySQL) and Windows - File Permissions
  • Use fig and docker-machine to deploy remotely
  • Benefits of deploying .NET Core App as a Dockerized Container?
  • One Solution collect form web for “GitLab CI: How to pull specific docker container for deployment”

    As mentioned in the comments to your question, simply use the same script you used to push the image, to pull it in the deploy stage.

    Here’s an example pull.sh script:

    #!/bin/sh
    args=("$@")
    CI_REGISTRY_IMAGE=${args[0]}
    
    PACKAGE_VERSION=$(cat package.json \
    | grep version \
      | head -1 \
      | awk -F: '{ print $2 }' \
      | sed 's/[",]//g' \
      | tr -d '[[:space:]]')
    CONTAINER_RELEASE_IMAGE=$CI_REGISTRY_IMAGE\:$PACKAGE_VERSION
    docker pull $CONTAINER_RELEASE_IMAGE
    

    Notice the pull instead of the push in the last line.

    Then modify your deploy job like this:

    deploy_prod:
      stage: deploy
      script:
        - ./pull.sh $CI_REGISTRY_IMAGE
        # ...
      when: manual
      environment:
        name: productive
        url: https://example.com
      only:
        - master
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.