Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use docker exec to change /etc/hosts error #15604

Closed
Jam-Lin opened this issue Aug 15, 2015 · 1 comment
Closed

use docker exec to change /etc/hosts error #15604

Jam-Lin opened this issue Aug 15, 2015 · 1 comment

Comments

@Jam-Lin
Copy link

Jam-Lin commented Aug 15, 2015

hello, i use docker exec 1ebea17823f3 echo test >> /etc/hosts to change the container /etc/hosts, but i find that the container hosts do not change. it change the vm /etc/hosts.

@thaJeztah
Copy link
Member

I think this is expected, and not a bug in docker; basically what your doing is;

(docker exec 1ebea17823f3 echo test) >> /etc/hosts

(Added the parentheses to illustrate the problem) Basically, the echo test runs inside the container, but the output is returned to the host (vm) and added to /etc/hosts of the VM.

Try it this way, so that both the "echo" AND the >> /etc/hosts take place inside the container;

docker exec 1ebea17823f3 /bin/sh -c "echo test >> /etc/hosts"

I'm going to close this issue, because it's not a bug, but I hope the above explanation helps you further!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants