Connect to docker container as user other than root

后端 未结 9 1099
没有蜡笔的小新
没有蜡笔的小新 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 01:55

    The only way I am able to make it work is by:

    docker run -it -e USER=$USER -v /etc/passwd:/etc/passwd -v `pwd`:/siem mono bash
    su - magnus
    

    So I have to both specify $USER environment variable as well a point the /etc/passwd file. In this way, I can compile in /siem folder and retain ownership of files there not as root.

提交回复
热议问题