简体   繁体   English

Windows 容器内的 runas 或 psexec

[英]runas or psexec inside Windows container

I have a windows image based on mcr.microsoft.com/windows:1809 .我有一个基于mcr.microsoft.com/windows:1809的 windows 图像。

In my Dockerfile, I created a new user via在我的 Dockerfile 中,我通过

net user /add myuser mypassword

Now I would like to enter the container, eg via docker run -it and execute commands via the myuser (instead of the standard user ContainerAdministrator ).现在我想进入容器,例如通过docker run -it并通过myuser (而不是标准用户ContainerAdministrator )执行命令。

I tried both runas and psexec but both commands did not work as expected or gave various errors, among others these and these .我尝试了runaspsexec ,但两个命令都没有按预期工作或给出各种错误,其中包括这些这些

How can I run a command inside a Windows docker container as a different user other than ContainerAdministrator ?如何以ContainerAdministrator以外的其他用户身份在 Windows docker 容器中运行命令?

Use the --user arg while running "docker run" command.在运行“docker run”命令时使用--user参数。 In your case your user "myuser" will be the arg value as below在您的情况下,您的用户“myuser”将是如下的 arg 值

docker run -it --user "myuser" <image_id> cmd docker 运行 -it --user "myuser" <image_id> cmd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM