Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get root access inside mssql docker container

I created a MSSQL docker container based on the official image provided by Microsoft (https://hub.docker.com/_/microsoft-mssql-server).

I started a bash shell inside the running container and tried to delete some files.

sudo docker exec -it sql1 "bash"

Inside the container it is using the mssql account (by default).

And there seems to be some permission issues when I tried to delete the files.

rm -f *.csv
rm: cannot remove 'xxx.csv': Operation not permitted

How can I obtain the root permission to delete the file? I am not sure what default password I can use to run rm as root.

Thanks a lot!

like image 846
Zheng Avatar asked Dec 30 '25 07:12

Zheng


1 Answers

You can specify the user as an argument:

sudo docker exec -it --user root sql1 "bash"
like image 159
Chris Avatar answered Jan 01 '26 02:01

Chris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!