Reputation: 3221
I have a windows image based on mcr.microsoft.com/windows:1809
.
In my Dockerfile, I created a new user via
net user /add myuser mypassword
Now I would like to enter the container, e.g. via docker run -it
and execute commands via the myuser
(instead of the standard user ContainerAdministrator
).
I tried both runas
and psexec
but both commands did not work as expected or gave various errors, among others these and these.
How can I run a command inside a Windows docker container as a different user other than ContainerAdministrator
?
Upvotes: 2
Views: 1049
Reputation: 11
Use the --user arg while running "docker run" command. In your case your user "myuser" will be the arg value as below
docker run -it --user "myuser" <image_id> cmd
Upvotes: 1