Docker Community Forums

Share and learn in the Docker community.

Change the user and user home when running Windows image

How can I change the user running inside the docker?

On Linux docker I can do this by setting USER and HOME environment variables.
docker run -it -e USER=build -e HOME=/home/build -w /home/build/workspace/project image-name

I need to do the same for Windows docker.
docker run -it -e USER=build -e HOME=C:\Users\build -w C:/Users/build/workspace/project image-name

However this does not work on Windows. Seems like the user running is still ContainerAdministrator.

Do I need to set other environment variables when running Windows Docker?

HOME=C:/Users/build
USER=build
USERDOMAIN=User Manager
USERNAME=ContainerAdministrator
USERPROFILE=C:\Users\ContainerAdministrator

Edit: It had no effect changing these environment variables.
I have a file I need access to within the Docker image. This file is in the user home directory.
SignTool Error: File not found: C:\Users\ContainerAdministrator\certificate.pfx

A workaround: When running Gradle, to set -Duser.home=C:\Users\build