Packer: Should the docker run_command default use /bin/sh?

Created on 27 Mar 2015  路  10Comments  路  Source: hashicorp/packer

In 037a744be599a4dd5aeb94473da46467ff1971af, the default for run_command for docker was set to use /bin/bash. Given the shell provisioner defaults to /bin/sh, should that also be the default here?

I'm happy to make this change, but wanted to ask if there's a need to stick with bash before creating a pull request.

buildedocker question

Most helpful comment

I do see a serious issue with that. The decision to default to Bash causes failure to provision an Alpine Linux 3.2 Docker image, a GNU/Linux distro which does not contain Bash. The sensible thing to do is to rely on the default shell, not on Bash.

All 10 comments

I don't see an issue keeping it bash for now... especally for backwards compat reasons... let's just keep it that for now. I don't see any reason otherwise to have it be bash.

I do see a serious issue with that. The decision to default to Bash causes failure to provision an Alpine Linux 3.2 Docker image, a GNU/Linux distro which does not contain Bash. The sensible thing to do is to rely on the default shell, not on Bash.

@mitchellh
Question on this: I want to run Ansible from a VirtualEnv. I cannot do this if we enter with 'ansible-local' as /bin/sh on RHEL7 because there's no place to set non-interactive $PATH (as in no equivalent to .bashrc, (not talking about profile, as that is for interactive). The only way I can figure might solve this is to make a wrapper script in bash called 'ansible-playbook' that activates the virtualenv and hands off to the real 'ansible-playbook', but this is very ugly. An option of how to enter the container for 'ansible-local' would be amazing. Maybe it exists but I haven't seen that yet. Thoughts?

Edit: I verified that the wrapper in ~/bin works.. I was able to call it ansible-playbook-wrapper using the command: directive in Packer JSON.

I confirm that this causes issues with Alpine, since bash is not installed by default.

Also having a problem provisioning Alpine due to this issue

I also get hit by this.

Hit by this trying to use alpine:3.6.
Is the only way to go Dockerfile install bash with apk and then use those images in packer ?
Any way we can customize the docker run command for alpine /bin/sh ?

@mitchellh Any recommendations ?

@jerishsd see run_command.

Please only use _GitHub Issues_ for reporting bugs and feature requests. Do not ask for general help here. Use _IRC #packer-tool on Freenode_ or the mailing list for that.

See https://www.packer.io/community/

Was this page helpful?
0 / 5 - 0 ratings