containers / build

another build tool for container images (archived, see https://github.com/rkt/rkt/issues/4024)
Apache License 2.0
342 stars 80 forks source link

echo with acbuild run writes a file on the host #310

Closed jharshman closed 7 years ago

jharshman commented 7 years ago

AcBuild Version:

$ acbuild version
acbuild version v0.4.0
appc version 0.8.5

Given the following line:

acbuild run -- echo 'eval "$(rbenv init -)"' | tee /etc/profile.d/rbenv.sh

a file is generated on the host machine running acbuild rather than inside the container. The end goal here is to have eval "$(rbenv init -)" written into the file /etc/profile.d/rbenv.sh within the container image.

Is this misuse on my part or a bug?

cgonyeo commented 7 years ago

What's happening here is the shell on the host is interpreting the pipe and running the tee command, instead of those things being passed into acbuild. You can invoke a shell inside of acbuild to do the pipe logic for you if you wish:

acbuild run -- /bin/sh -c 'echo \'eval "$(rbenv init -)"\' | tee /etc/profile.d/rbenv.sh'
jharshman commented 7 years ago

Thanks for the quick reply! Seems to be something funky going on with the quotes though. Here's what got it working.

acbuild run -- /bin/sh -c "echo 'eval \"\$(rbenv init -)\"' | tee /etc/profile.d/rbenv.sh"