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.
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!
Most helpful comment
I think this is expected, and not a bug in docker; basically what your doing is;
(Added the parentheses to illustrate the problem) Basically, the
echo testruns _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/hoststake place inside the container;I'm going to close this issue, because it's not a bug, but I hope the above explanation helps you further!