LoginSignup
6
2

More than 5 years have passed since last update.

[Docker] debian系のコンテナでrootユーザーになる方法

Last updated at Posted at 2019-04-24

結論

docker runのオプションで指定してあげる必要あり

docker run -it --rm -u root --entrypoint /bin/sh hoge:1.1.1

なぜdocker runの段階なのか

  • rootユーザーのパスワードがわからないのでコンテナの中に入ってからsu rootはできない
  • sudoコマンドはdebianではデフォルトでインストールされていない。インストールしようとするとsu rootする必要が出てくるが、パスワードがわからないのでインストールできない

参考: https://unix.stackexchange.com/a/425664

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2