본문 바로가기

오늘의 비글링/개발 프로그램

[Docker] 컨테이너에서 sudo 사용하기

 

  • sudo 설치

    $ apt-get udpate && apt-get install -y sudo

  • 사용자 계정 추가

    $ adduser --disabled-password --gecos "" hive \ && echo 'hive:hive' | chpasswd \ && adduser hive sudo \ && echo 'hive ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \ && mkdir /var/run/sshd

    • 이 때 sudoers에 추가한 유저에 대한 설정을 하지 않으면 sudo를 사용할 수 없다.

    • /etc/sudoers의 내용을 보면 %sudo로 시작하는 설정이 있는데 이는 sudo group에 속한 유저에 대한 권한 설정이다.

    • NOPASSWD 설정을 해주지 않으면 sudo 그룹에 속한 유저라도 아래와 같이 최초 한번 비밀번호를 물어보게 되므로 Dockerfile 빌드 시 에러가 난다.

      We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. sudo: no tty present and no askpass program specified



출처: https://yongho1037.tistory.com/720 [개발 노트]

 

 

[Docker] 컨테이너에서 sudo 사용하기

sudo 설치 $ apt-get udpate && apt-get install -y sudo 사용자 계정 추가 $ adduser --disabled-password --gecos "" hive \ && echo 'hive:hive' | chpasswd \ && adduser hive sudo \ && echo 'hive ALL=(ALL)..

yongho1037.tistory.com