I am trying to execute a command on a docker container that is running in a remote server. I am running most commands through ssh and they all work correctly. However, this command modifies the file /etc/environment and I get a "permission denied" error.
The command in question is docker exec container_id echo 'WDS_SOCKET_PORT=XXXXX' >> /etc/environment
- If I run the command from the docker host, it works
- If I run a simple command remotely using
ssh user@ip docker exec container_id ls, it works - If I run this command remotely using
ssh user@ip docker exec container_id echo 'WDS_SOCKET_PORT=XXXXX' >> /etc/environmentI getsh: 1: cannot create /etc/environment: Permission denied
I tried adding the option -u 0 to the docker exec command with no luck.
I don't mind making changes to the Dockerfile since I can kill, remove or recreate this container with no problem.