Home > Blockchain >  Docker: How to use "docker/compose" container?
Docker: How to use "docker/compose" container?

Time:03-04

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?

CodePudding user response:

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).

CodePudding user response:

Try installing docker-compose within dind (docker-in-docker), like so:

FROM docker:20.10-dind
RUN apk add docker-compose
WORKDIR /
COPY ./docker-compose.yml .
COPY ./.env .
CMD [ "docker-compose", "up"]
  • Related