Step 2: Create a container binding host’s ./env_container1 to container’s /.env
host: docker run -ti -v $(pwd)/.env_container1:/.env alpine sh
Step 3:
host: sed -i 's/old/new/g' .env_container1
Step 4:
The expected behaviour would be that the old will be substituted to new. However, when I run cat test it outputs the old value
container: cat .env
May I know why will sed break the binding between the host and the container? This will not be an issue if i mount a directory and sed the file from the directory. But at the same time i would like the file in the host filesystem and the container filesystem to have a different name
sed renames the original file and then creates a new with the name of the old one. It is clearer what happens if you use sed -i.old ....
On my system (Docker Desktop + WSL) I get with both Alpine and Debian a ‘Device or resource busy’ error when I try to edit in-place.