Connect to docker container as user other than root

后端 未结 9 1027
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 01:38

BY default when you run

docker run -it [myimage]

OR

docker attach [mycontainer]

you connect to the terminal as r

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 02:09

    This solved my use case that is: "Compile webpack stuff in nodejs container on Windows running Docker Desktop with WSL2 and have the built assets under your currently logged in user."

    docker run -u 1000 -v "$PWD":/build -w /build node:10.23 /bin/sh -c 'npm install && npm run build'
    

    Based on the answer by eigenfield. Thank you!

    Also this material helped me understand what is going on.

提交回复
热议问题