Add option to change current directory and use sudo in docker_image
Here's a link to the change I had to make in the image provider to get docker_image to work in OpsWorks:
https://github.com/amjibaly/chef-docker/commit/b2e5e19f01683d95a1170a64d94b7697a47bb43c
I also had to make the following change in helpers.rb:
https://github.com/amjibaly/chef-docker/commit/a75416b1e1c14b576a5922318c6ca7c0b48b75f6
Interesting. Is anyone else running into this? I don't personally use OpsWorks. Does Amazon have any documentation about this? I'm hesitant to add this without a platform check as it seems very specific.
You can take a look at some of their examples (all their recipes are in github). For example:
https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.4/opsworks_nodejs/libraries/nodejs_configuration.rb
FWIW, I'm finding that building images during deployment seems to be a bad practice anyways so I think long term I'm going to avoid doing that in OpsWorks.
Hmm I would think that sudo/su -c would only be necessary for application-specific actions (installing NPM packages/Rubygems in those recipes). Does the docker image command give any useful output when its not working? Docker logs? I'll leave it up to you if you want to keep this open or not.
When I run the docker build command as the default ubuntu user it fails as well. I think part of the problem was some missing env vars (like DOCKER_HOST) but I'm not sure if that was all. It could be something related to setup recipes (where I'm installing docker using include_recipe 'docker') being run as root and deploy recipes being run as non-root in OpsWorks.
If it's not affecting anyone else I'd be in favor of closing it for now.
Ah in that case, you'll need to make sure whoever is not root that's running docker is part of the docker group. Otherwise they cannot connect to the default socket. There's an attribute you can set to add them to the group. Or you can enable the different daemon host option and set DOCKER_HOST= in the environment for the user.
Very cool, sounds like the group_members attribute? It's not clear what I'd put in that array, is it just the name of the user I'd want to add (in addition to the root user)?
Garbage collecting this issue... feel free to re-open if this is still a thing.