Docker Community Forums

Share and learn in the Docker community.

Starting a container from a container with docker-compose


first of all, I am using Docker Desktop on Windows, and I strongly believe, that my problem is completely Windows specific. Sorry for that!

I have learned, that I can launch a container from another container by using the option

    docker container run -v /var/run/docker.sock:/var/run/docker.sock

when launching the fatter container with “docker run”. Good to know!

I’d prefer, though, if I could have the same with docker-compose. I tried the snippet below

        - dockerSock:/var/run/docker.sock:/var/run/docker.sock

However, upon “docker-compose up”, I am getting the error message “Cannot create container for service MYSVC: invalid mode: /var/run/docker.sock”. I suspect, because docker-compose doesn’t have the perspective of a running docker daemon, so doesn’t know, what /var/run/docker.sock might be.

Is it possible, to convince docker-compose to launch anyways? Or any other workaround?



Get started with Docker Compose
Step 1: Setup. …
Step 2: Create a Dockerfile. …
Step 3: Define services in a Compose file. …
Step 4: Build and run your app with Compose. …
Step 5: Edit the Compose file to add a bind mount. …
Step 6: Re-build and run the app with Compose. …
Step 7: Update the application. …
Step 8: Experiment with some other commands.