From c97303b9a6835f2cd60dd0b7f31889f8ccfb615f Mon Sep 17 00:00:00 2001
From: Quentin Duchemin <quentinduchemin@tuta.io>
Date: Fri, 10 Apr 2020 01:13:42 +0200
Subject: [PATCH] [CI] Fix docker-bench-security not allowed to pull from
 production registry

---
 .gitlab-ci.yml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e0bdb692..ff16431f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -144,12 +144,15 @@ docker-bench-security:
     - "sed -i -e 's/external: true/external: false/g' $MODIFIED_IMAGE/docker-compose.yml"
     - cat $MODIFIED_IMAGE/docker-compose.yml
     - cd $MODIFIED_IMAGE
+    # Login on the production registry, in case there is another image in Docker Compose stored on the production registry
+    - docker logout $REGISTRY
+    - echo $REGISTRY_PROD_PASSWORD | docker login $REGISTRY_PROD -u $REGISTRY_PROD_USERNAME --password-stdin
     - docker-compose up -d
     - git clone https://github.com/docker/docker-bench-security.git
     - cd docker-bench-security
     - sh docker-bench-security.sh -c container_images,container_runtime,docker_security_operations,community_checks -l ../../report.txt
   after_script:
-    - docker logout $REGISTRY
+    - docker logout $REGISTRY_PROD
   artifacts:
     paths:
       - report.txt
-- 
GitLab