2

Can we add docker.sock from host to container using Dockerfile? What I want to do is issue docker commands (pull, tag and push) inside container. I know the "-v /var/run/docker.sock:/var/run/docker.sock" in docker run command but I need to include the same inside Dockerfile to build it. Here below is my Dockerfile :-

FROM centos:latest
RUN yum update -y && yum install epel-release -y
RUN yum install python-pip -y
RUN pip install requests
COPY docker_push.py /tmp
COPY config.ini /tmp
RUN yum install docker-io -y
ENTRYPOINT ["python", "/tmp/docker_push.py"]
Kalim
  • 183
  • 1
  • 3
  • 12
  • Possible duplicate of [Is it ok to run docker from inside docker?](https://stackoverflow.com/questions/27879713/is-it-ok-to-run-docker-from-inside-docker) – jannis Jul 03 '19 at 08:47

1 Answers1

1

Possible duplicate of : Add bind mount to Dockerfile just like volume

TL;DR:

A Dockerfile is just a description of how an image is built. The act of binding a volume is host-specific, so it could be defined only when a container will instantiate this image.

As a substitute of passing the argument -v at docker run, you could also use a compose file to manage it :

version: '3'
services:
  XXXX:
    build: YYYYY
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
Community
  • 1
  • 1
ygouzerh
  • 11
  • 2