I want to run Docker Compose inside a Docker container using the official docker/compose container.
My Dockerfile
looks like this:
FROM docker/compose:latest
WORKDIR /
COPY ./docker-compose.yml .
COPY ./.env .
CMD [ "docker-compose", "up"]
Running docker build -t my-container .
works. But running docker run --privileged my-container
fails with:
> Couldn't connect to Docker daemon at http+docker://localhost - is it running?
>
> If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
What am I doing wrong? Do I have to specify DOCKER_HOST
, and if yes, to what?
3
Answers
I guess the image docker/compose is used to in order to build docker-compose tool not to launch docker inside.
It’s designed to be used by someone who would edit docker-compose source code.
However you could use the
dind
image (docker in docker).Try installing
docker-compose
withindind
(docker-in-docker), like so:Try
docker run -v /var/run/docker.sock:/var/run/docker.sock -it container_name
It will share docker socket.