3

I am running Windows Nanoserver in a container.The nanoserver contains only the command prompt and lacks powershell.

I want to execute certain commands inside the container in the command prompt which require elevated privileges. I am currently using the following to launch the command prompt of the container.

docker exec -it <container_id> cmd

Is there any other way using which we can run the command prompt in admin mode?

Harsh Rawat
  • 151
  • 1
  • 3
  • As far as I remember UAC is disabled on Server Core, most likely on Nano Server as well, so you don't have to deal with UAC, if you are an administrator, you are already elevated. Can you run `whoami /groups` – Peter Hahndorf Mar 17 '21 at 07:36
  • I am not able to run the `whoami` command. The error received is `'whoami' is not recognized as an internal or external command, operable program or batch file.` – Harsh Rawat Mar 17 '21 at 09:03
  • 1
    If I use `echo %username%` then the user displayed is `ContainerUser`. As per the documentation, the default user is `"ContainerAdministrator" on Windows Server Core and "ContainerUser" on Nano Server containers` – Harsh Rawat Mar 17 '21 at 09:06

1 Answers1

2

As per the Windows Containers documentation, the Windows Server Core has ContainerAdministrator as the default user whereas Windows NanoServer has ContainerUser as the default user.

Thanks to Peter's comment, I was able to connect to my container as admin using the following command-

docker exec --user ContainerAdministrator -it <container_id> cmd

mloskot
  • 543
  • 1
  • 4
  • 6
Harsh Rawat
  • 151
  • 1
  • 3