docker
docker copied to clipboard
docker_image does not support running from a directory
Dockerfile ADD commands are often relative to a directory, but the docker_image command doesn't support any sort of "run from this directory" command. You can work around this by choosing a directory instead and this works for most situations, but it would be a useful addition.
Sure it does.
https://github.com/chef-cookbooks/docker/blob/master/test/cookbooks/docker_test/recipes/image.rb#L129-L148
Sorry, I should clarify. It supports "run from this directory" if the file you want to build from is called "Dockerfile". It doesn't support the use case I had, which was "run from this directory, but use this differently named file as the Dockerfile" (because I actually had two different Dockerfile's I wanted to run that were both in that directory). I solved this in my case by splitting everything up into separate folders and renaming the files to Dockerfile, but that won't fix everyone's situations.
I'm trying to figure out what support for this would look like....
First thing would be the interface... I image we'd need a property on docker_image and an example of it being exercised somewhere near here:
https://github.com/chef-cookbooks/docker/blob/master/test/cookbooks/docker_test/recipes/image.rb#L103-L105
Then somehow tweak this function: https://github.com/chef-cookbooks/docker/blob/master/libraries/helpers_image.rb#L9
It really boils down to if the underlying docker-api rubygem supports doing this.
-s
The underlying API definitely supports it. One of the examples from docker-api is Docker::Image.build_from_dir('.', { 'dockerfile' => 'Dockerfile.Centos' }) i.e. specifying directory and Dockerfile name