Issue
I'm trying to take the 3 commands I use below, and either make it into a single command, or put it in a script that I can call from another program.
This is what i'm currently doing:
$ sudo docker exec -it <my-app container id> bash
$ chmod +r /var/opt/mssql/data/myFile.bak
$ exit
Is there an easier way to chmod a file inside a docker container? If not, how can I put this in a single command, or a single script?
This does NOT work:
$ sudo docker exec -it <my-app container id> bash; chmod +r /var/opt/mssql/data/myFile.bak; exit
Solution
I assume you have a running container, and you want to chmod a file into it. This change will likely be bound to the lifetime of the container unless that file is on a volume.
docker exec <my-app container id> bash -c 'chmod +r /var/opt/mssql/data/myFile.bak'
Execute with sudo
if needed by your setup. Assumes bash
is in the container's PATH
and that the user the container is executed with has the right ownership to execute chmod
.
You don't need -it
because it's not an interactive session, only a single process execution inside the container.
Answered By - giorgiosironi Answer Checked By - Robin (WPSolving Admin)