Can I use volumes in Drone Cloud in order to map /var/run/docker.sock?

I need to know the docker image id in the registry to include it in the Heroku API request in order to perform a release. To do that I use docker inspect tag --format={{.Id}} inside alpine image and install docker-cli to that. In order docker command to work I need a volume mapping from host /var/run/docker.sock to container /var/run/docker.sock.

steps:
  - name: release
    image: alpine
    volumes:
      - name: dockersock
        path: /var/run/docker.sock
    commands: [...]

volumes:
  - name: dockersock
    host:
      path: /var/run/docker.sock

But this causes build error in cloud.drone.com with the message “default : error”.

What I do wrong? Maybe some alternative solution will be better?

pipeline cannot mount volumes by default, for security reasons. we therefore do not allow volumes to be mounted at drone cloud, however, you always have the option to self-host Drone on your own infrastructure.

1 Like

Hi @karatach1998, I had a similar case and worked around it without a volume mount, which I believe is still possible on Drone Cloud. Example below:

kind: pipeline
type: kubernetes
name: default

steps:
- name: release
  image: docker:dind
  environment:
    DOCKER_HOST: tcp://docker:2375
  commands:
  # wait for docker service to be up before running docker build
  - n=0; while [ "$n" -lt 60 ] && [ ! docker stats --no-stream ]; do n=$(( n + 1 )); sleep 1; done
  - ...

services:
- name: docker
  image: docker:dind
  environment:
    DOCKER_TLS_CERTDIR: ""