我已經跑了Ubuntu的空泊塢窗容器並創建了一個用戶sudo
這樣:如何編寫docker腳本,以便sudo在Docker用戶中工作?
[email protected]$ docker run -it ubuntu bash
[email protected]:/# apt-get update
[email protected]:/# apt-get -y install sudo
[email protected]:/# useradd -m -p mosesdocker -s /bin/bash ubiwan
[email protected]:/# usermod -aG sudo ubiwan # add user to sudo list
[email protected]:/# su - ubiwan # login to the ubiwan user
當我登錄的ubiwan
,密碼似乎並沒有被mosesdocker
由useradd -m -p mosesdocker -s /bin/bash ubiwan
規定。我輸入了正確的密碼,但我得到:
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
[email protected]:~$ sudo su
[sudo] password for ubiwan:
Sorry, try again.
[sudo] password for ubiwan:
Sorry, try again.
[sudo] password for ubiwan:
sudo: 3 incorrect password attempts
這是爲什麼?
是否可以在Docker中使用sudo
?什麼是「建議」在Docker中執行sudo
操作?
如何編寫docker腳本以便sudo在Docker用戶中工作?
Stack Overflow是編程和開發問題的網站。這個問題似乎與題目無關,因爲它不涉及編程或開發。請參閱幫助中心的[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)。也許[請求Ubuntu](http://askubuntu.com/)或[Unix&Linux Stack Exchange](http://unix.stackexchange.com/)會是一個更好的地方。另請參閱[我在哪裏發佈有關Dev Ops的問題?](http://meta.stackexchange.com/q/134306) – jww