40
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?