Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default user for Linux Alpine?

I am running a Dockerfile here and want to "change back" to the regular Linux Alpine user, after following this to setup memcached.

FROM python:3.6-alpine

# Bunch of Linux / Django / Node stuff

COPY boot.sh /boot.sh
RUN apk --no-cache add memcached && chmod +x /boot.sh

USER memcached
CMD ["/boot.sh"]

# Change back to default user here
USER root

ADD docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]

What is the syntax for this? I have used USER root for the time being. Is this correct? I don't reference USER anywhere before USER memcached.

like image 928
Scott Skiles Avatar asked Mar 04 '19 18:03

Scott Skiles


1 Answers

I believe USER root is correct. The default docker user is typically root.

The closest reference I could find is in the Docker docs for the USER command:
https://docs.docker.com/engine/reference/builder/#user

Warning: When the user doesn’t have a primary group then the image (or the next instructions) will be run with the root group.

However, it very easy to find for yourself, using a simple Dockerfile:

FROM python:3.6-alpine
RUN whoami

Will output (either ifdocker is started as root or as a Docker previliged user):

Step 2/2 : RUN whoami #
 ---> Running in 3a8d159404cd
root
like image 187
valiano Avatar answered Oct 27 '22 19:10

valiano