Skip to content

thomas-hilaire/volumes_docker-compose_in_docker

Repository files navigation

The goal

I need to share local folders as volumes into some containers of a docker-compose.

I don't want docker-compose to be a dependency of my project, but docker only. So I want to use docker-compose in docker.

The problem

Using the volumes instruction into my docker-compose.yml file work only when I run it with docker-compose directly, but not with docker-compose in docker.

The output with docker-compose is :

$ ./runDockerCompose
Starting want-config-container
Attaching to want-config-container
want-config-container | /config-absolute
want-config-container | /config-relative
want-config-container | /config-relative/two
want-config-container | /config-relative/two/file
want-config-container | /config-relative/one
want-config-container | /config-relative/one/file

The output with docker-compose in docker is :

$ ./runDockerComposeInDocker.sh
Recreating want-config-container
Attaching to want-config-container
want-config-container | /config-absolute
want-config-container | /config-relative

So, how can I get my shared-config folder mounted into my want-config-container ?

Note

I have try to make a container dedicated to hold my config.

I run it with my local config folder as a volume, then make my docker-compose containers linked to it. But it's impossible as I can't use volumes_from against a external_links container.

Solution

Make the volumes using an absolute path from the host:

$ ./runDockerComposeInDockerWithAbsolutePath.sh
Recreating want-config-container
Attaching to want-config-container
want-config-container | /config-absolute-from-host
want-config-container | /config-absolute-from-host/two
want-config-container | /config-absolute-from-host/two/file
want-config-container | /config-absolute-from-host/one
want-config-container | /config-absolute-from-host/one/file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages