LoginSignup
2
2

More than 1 year has passed since last update.

Dockerのコンテナでsudoできない場合の対処法

Last updated at Posted at 2023-03-15

Dockerコンテナ内でsudo ...と叩いてもbash: sudo: command not foundと出てきた。
イメージにユーザーを追加するほどでもなく、ちょっとsudoコマンドで作業したい場合に超有効。

docker-compose.ymlの場合

docker-compose.yml
docker-compose exec -u 0 コンテナ名 bash

Dockerfileの場合

Dockerfile.
docker exec -it -u 0 コンテナ名

これを覚えておくとかなり融通が効くかと思います^^

参考:Docker:sudoできないDockerコンテナを、rootでシェル操作するには

2
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
2
2