Trying to run the command below:
docker container exec container-name echo '. $HOME/.asdf/asdf.sh' >> /root/.bashrc
but I'm getting the error below:
warning: An error occurred while redirecting file '/root/.bashrc'
open: Permission denied
I just created the container. I can get into the container as root and execute the same command without error. Does anybody know what I'm missing?
CodePudding user response:
You are trying to write in your host's root user .bashrc
. It is good that you didn't run this as user root on host.
I think this is what you actually want:
docker container exec container-name sh -c 'echo . $HOME/.asdf/asdf.sh >> /root/.bashrc'
Also you can use /root
instead of $HOME
since you already use that in the second part of the command.