Quantcast
Channel: 개발 노트
Viewing all articles
Browse latest Browse all 299

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

$
0
0
  1. sudo 설치

    $ apt-get udpate && apt-get install -y sudo
  2. 사용자 계정 추가

    $ 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
      


저작자 표시비영리변경 금지

Viewing all articles
Browse latest Browse all 299

Trending Articles