Mounting Docker socket in composition step

I was referring to the guide here to access the Docker daemon in a Codefresh step.

This is the thread I referred to before starting this issue: Shared volumes in freestyle composition - #12 by rsung

The reason for doing this is in our tests, we have a Docker in Docker setup (we wanted to try this out), so in the test itself we need to connect to the Docker daemon to pull additional images. I would rather not install Docker in the image directly as I read there are many issues that may arise.

My codefresh.yml file:

version: '1.0'
build_version: 'v2'
mode: parallel
stages:
- setup
- test

steps:
  main_clone:
    title: Cloning main repository...
    type: git-clone
    repo: '${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}'
    revision: '${{CF_REVISION}}'

  build_builder:
    type: build
    stage: setup
    title: Build builder image
    dockerfile: Dockerfile
    image_name: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}-builder
    disable_push: true
    tag: latest
    when:
      steps:
      - name: main_clone
        on:
        - success

  test:
    title: Run tests
    type: composition
    stage: test
    working_directory: ${{main_clone}}
    environment:
    - GOPATH=/codefresh/volume/.go
    composition:
      version: '2'
    composition_candidates:
      run-test:
        image: ${{build_builder}}
        command: ./test.sh
        volumes: # Volumes required to run DIND and to mount your Repository
          - /var/run/docker.sock:/var/run/docker.sock
          - /var/lib/docker:/var/lib/docker
          - ${{CF_VOLUME_NAME}}:/codefresh/volume
    when:
      steps:
      - name: build_builder
        on:
        - success

I got the following errors:

Cannot start composition with warnings ["Volume mapping is not supported, try
use: /var/run/docker.sock","Volume mapping is not supported, try use: /var/lib/doc
ker"]

I am not sure if it is one of the following reasons:

  1. I’m using composition wrongly or my codefresh.yml syntax is wrong
  2. Volume mapping is no longer supported in composition steps, OR
  3. Accessing the Docker daemon is no longer supported in composition steps.

Hello

For security reasons, this is not allowed in the SAAS version of Codefresh. We updated the knowledge article to reflect this.

While you can use the Codefresh runner for the hybrid installation, I think a better course of action is to simply refactor your code and not use the docker socket directly (which is a good practice anyway)

Sorry for the confusion.