cider-security-research / cicd-goat

A deliberately vulnerable CI/CD environment. Learn CI/CD security through multiple challenges.
Apache License 2.0
1.93k stars 320 forks source link

gitlab pipeline Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock #69

Closed bfengj closed 9 months ago

bfengj commented 12 months ago

when i start the pipeline in nest-of-gold and awesome-app:

image

i try many methods but fail to solve it.Can you tell me how to solve it?

bfengj commented 12 months ago

I find why it happens.My computer is mac m1 arm64,usually i use env DOCKER_DEFAULT_PLATFORM=linux/amd64 to be compatible with other service's docker image which don't support arm64.So i build cicd-goat in amd64.Usually it's fine when other images,but cicd-goat can't.So I change the env DOCKER_DEFAULT_PLATFORM=linux/arm64 and change the docker-compose.yaml:

version: "3.8"

networks:
  goat:
    driver: bridge

services:
  jenkins-server:
    image: cidersecurity/goat-jenkins-server:latest
    networks:
      - goat
    container_name: jenkins-server
    restart: always
    ports:
      - "8080:8080"
      - "50000:50000"
  jenkins-agent:
    image: cidersecurity/goat-jenkins-agent:latest
    container_name: jenkins-agent
    restart: always
    networks:
      - goat
    environment:
      - JENKINS_AGENT_SSH_PUBKEY=ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC33zkdtvwp8giZLp1mVUbqzCKi0KIiWD8/towT0+9k1SCDYjJ/YVPqKidkSefYaKBgJ1yFcWa9qroXAUd5nACXN3Xdes2fe4w+xZ8GQTpqHKyStEHy6R9QXi00r/VxGcmBYZWLifEyzV//PiRC+hUaG27JeeBnkZ1FEOyXUunpaPixNaDkfnLbCimflkd2uYH2arMY+FdOH950ezow/+v4vsNrzoMwVVCCSg/dIJBS2G/JaoAbbQgIGo63Kyz0j++rIInsXMFmxhy9hEpViX/tEorFzGh4gUvJPLy3IDjWjUz/Nfte9By6usQjN/1plJcuP+rUqrjjGeMpfhDP6aq5ZvfuPTmXOVkWJ9vJZaK2BCtSZk1vOJR4luxCyUZQbKgb3jS9YZ4N1ZS26z3EKwJGP/acNtEMx2u2zhY7zXdG7ca1Qo1yeVDMRctlvH++KMEYX/ZR6LqYlJyV6TFICZVUT7dLF65gq68UyIFswMu9pQ8/VvIMkkO6eiU1cqFr8gc=
  gitea:
    image: cidersecurity/goat-gitea:latest
    container_name: gitea
    restart: always
    environment:
      - USER_UID=1000
      - USER_GID=1000
    networks:
      - goat
    ports:
      - "3000:3000"
  ctfd:
    image: cidersecurity/goat-ctfd:latest
    platform: linux/amd64
    container_name: ctfd
    restart: always
    ports:
      - "8000:8000"
    networks:
      - goat
  localstack:
    image: localstack/localstack:0.14.1-amd64
    platform: linux/amd64
    container_name: localstack
    restart: always
    networks:
      - goat
  prod:
    image: cidersecurity/goat-prod:latest
    container_name: prod
    privileged: true
    restart: always
    networks:
      - goat
    ports:
      - "8008:80"
      - "2222:22"
  gitlab:
    image: cidersecurity/goat-gitlab:latest
    container_name: gitlab
    restart: always
    hostname: 'gitlab'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab'
        registry_external_url 'https://gitlab:5050'
        letsencrypt['enable'] = false
        gitlab_rails['initial_shared_runners_registration_token'] = "GR1348hansd87fyzDiqyZeuHuxe"
        gitlab_rails['smtp_enable'] = false
        gitlab_kas['enable'] = false
        sentinel['enable'] = false
        logrotate['enable'] = false
        pages_nginx['enable'] = false
        grafana['enable'] = false
        prometheus_monitoring['enable'] = false
        alertmanager['enable'] = false
    networks:
      - goat
    ports:
      - '4000:80'
      - '5050:5050'
    shm_size: '256m'
  gitlab-runner:
    image: cidersecurity/goat-gitlab-runner:latest
    privileged: true
    container_name: gitlab-runner
    restart: always
    networks:
      - goat
    shm_size: '256m'
  docker:
    image: docker:20.10.21-dind
    privileged: true
    container_name: docker
    restart: always
    environment:
      DOCKER_TLS_CERTDIR: ""
    command: --insecure-registry=gitlab:5050
    networks:
      - goat

then everything is fine.

TupleType commented 9 months ago

Thank you for the solution, looks like an environment specific case so I'll close the issue