LoginSignup
40
22

More than 5 years have passed since last update.

Alpineのユーザー追加にハマった話

Posted at

Dockerfile

#alpine-image
FROM alpine

#user
RUN echo 'root:root' |chpasswd
RUN useradd -m walrein \
    && echo "walrein ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
    && echo 'walrein:walrein' | chpasswd

なんてことをしていたんですが、

[91m/bin/sh: /usr/sbin/useradd: not found

とか言われて検索したら

Best way to add user? #38
https://github.com/gliderlabs/docker-alpine/issues/38

このForumに助けられました

So, two things here:

There is a adduser that is handled by BusyBox. You are probably looking for adduser -S moxi.
You are trying to install a Debian package on Alpine. This won't work! You need either a musl compatible binary or a way to compile from source.

要はuseraddじゃなくてadduser使うんだよってことらしく

#alpine-image
FROM alpine

#user
RUN echo 'root:root' |chpasswd
RUN adduser -S walrein \
    && echo "walrein ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
    && echo 'walrein:walrein' | chpasswd

修正したら問題なくビルド出来ました

40
22
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
40
22