docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
33.86k stars 5.21k forks source link

Add `copy` to the yaml configuration #1664

Closed riquito closed 9 years ago

riquito commented 9 years ago

I want to deploy different services using the same image but with a different configuration file. Currently to achieve that I can

The first solution isn't feasible and the second it's overkill. I just want to copy a file, not keep it in sync

Proposed configuration:

myservice:
    image: foo/bar
    copy:
        - src:dest
axklim commented 7 years ago

+1

burningalchemist commented 7 years ago

+1 for reopening or different solution without volumes.

Currently using Environment variables in docker-compose.yml and j2 in docker-entrypoint.sh for parsing them to configuration files before running the main app of the container. Works for me, though it's a custom image and it can't be used out of the box with already available complete images.

budzek commented 7 years ago

+1

patrickjm commented 7 years ago

+1

b0laj1 commented 7 years ago

+1

mizanRahman commented 7 years ago

+1

oiwn commented 7 years ago

+1

kooliahmd commented 7 years ago

+1

nubitech commented 7 years ago

+1

storytime commented 7 years ago

+1

mmontossi commented 7 years ago

+1

jeroiraz commented 7 years ago

+1 for reopening

To add the possibility to have a different yaml file for each container instead of a config based on environment variables

ecoulon commented 7 years ago

+1 very needed feature

damianvalderrama-olx commented 7 years ago

+1 , nice to have feature!

andreymaznyak commented 7 years ago

+1

vlean commented 7 years ago

+1

jjortega commented 7 years ago

+1

konstan commented 7 years ago

+1

hieudang9 commented 7 years ago

+1 reopening. Bookmarked

shatil commented 7 years ago

+1 this is a much-needed feature.

If there was some way to mark a shared volume as a layer, so the volume remained RO but the writes applied to a layer atop, I'd live happily without a copy directive. I'd like to share, for example, an extracted build artifact, but the service writes to that directory (logs or PID file, etc.).

christabone commented 7 years ago

+1

MichalKalita commented 7 years ago

+1

omani commented 7 years ago

+1

OlegVorobyov commented 7 years ago

+1

sergio-jara commented 7 years ago

+1

Julien00859 commented 7 years ago

+1

kolyaflash commented 7 years ago

+1

ikrauchanka commented 7 years ago

+1

che commented 7 years ago

+1

ghost commented 7 years ago

+1 For reopening as it would be a very useful feature

Julien00859 commented 7 years ago

Maybe the template feature of https://github.com/jwilder/dockerize can help some of you

BlueHotDog commented 7 years ago

+1

hubun commented 7 years ago

+1

sylvain261 commented 7 years ago

+1

tindleaj commented 7 years ago

+1

vegasbrianc commented 7 years ago

+1

zmellal commented 7 years ago

+1 to reopen the issue

leshcat commented 7 years ago

+1

zmellal commented 7 years ago

Use docker secrets, in this example secrets are used with nginx image to copy server certificat and the config file https://docs.docker.com/engine/swarm/secrets/#intermediate-example-use-secrets-with-a-nginx-service

washtubs commented 7 years ago

That's a good point. Honestly it seems that since we already have secrets, we should have copy, as secrets are, in a way, just a specific type of file that you would copy over. Namely, one which is more carefully provisioned, which we don't need for config files.

It beats host mounting a volume for every configuration file you want included.

Oleffka commented 7 years ago

As said before:

... volumes:

washtubs commented 7 years ago

The reason copy is better, a) in swarm environments, where hosts are in fact separate machines, you should not have to have the exact same file in the same place on every machine. b) Copy can also be restricted to the folder compose is in, whereas a host mount requires an absolute path. c) I think the point of docker is to minimize the number of places that the contained application breaks into the host. Host mounts, even when configured as read-only, create a responsibility on the host to have and preserve files. We shouldn't have to use host mounts to solve this simple problem.

I think copying could be modeled similarly to the docker build process, where the Dockerfile is usually shipped in a git repository, along with all the files it needs to send to the build context. The Dockerfile isn't permitted to send anything that exists outside of it's directory structure, even if it's symlinked correctly. We could have a similar thing with compose, where src is restricted to the directory (and those below) of the docker-compose.yml. Basically, the workflow would be, docker-compose creates the container, and then for every src:dst pair, find the src under the current directory, and copy it into the unstarted container, then start the container.

Currently, avoiding host mounts can be achieved by adding additional Dockerfiles and building the conf files into amended images, but this seems like overkill to me, as it involves retagging a new image, or forcing users to use docker-compose build attribute instead of the more preferable (IMO) image attribute. If you're already using the build attribute in your service definition, and you want to do things this way, you are forced to pollute your otherwise agnostic image builder with a highly opinionated configuration file that should just belong to compose and the deployment process.

paulwilton commented 7 years ago

+1 for docker-compose copy feature

and1990 commented 7 years ago

+1

Xplouder commented 7 years ago

+1

kfrendrich commented 7 years ago

+1

rajeshkaushik commented 7 years ago

+1 for copy.

PMDubuc commented 7 years ago

+1 for docker-compose copy feature. I think the arguments in favor above are compelling.

ykalinov commented 7 years ago

+1 for copy

armadadean commented 7 years ago

+1 for copy.

Although in my POV. It can become handy but it can also become out of control or abused for many users and can even make volume obsolete. If you just need files to be put onto the container especially for swarm then you can just use configs or secrets; But for my case like putting static folders in a nginx container, I have to use multi-stage builds in my Dockerfile to put those static folders in the container which takes a lot of process before my goal is achieved. So I think adding a copy option could be very useful