Skip to content

Instantly share code, notes, and snippets.

@briceburg
Created March 30, 2016 22:17
Show Gist options
  • Select an option

  • Save briceburg/47131d8caf235334b6114954a6e64922 to your computer and use it in GitHub Desktop.

Select an option

Save briceburg/47131d8caf235334b6114954a6e64922 to your computer and use it in GitHub Desktop.
docker - example adding www-data user to alpine images
FROM nginx:alpine
# stock verison from php:alpine image
# ensure www-data user exists
RUN set -x \
&& addgroup -g 82 -S www-data \
&& adduser -u 82 -D -S -G www-data www-data
# 82 is the standard uid/gid for "www-data" in Alpine
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2
# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
FROM nginx:alpine
# modified version from php:alpine image
# ensure www-data user exists
RUN set -x ; \
addgroup -g 82 -S www-data ; \
adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1
# 82 is the standard uid/gid for "www-data" in Alpine
# http://git.alpinelinux.org/cgit/aports/tree/main/apache2/apache2.pre-install?h=v3.3.2
# http://git.alpinelinux.org/cgit/aports/tree/main/lighttpd/lighttpd.pre-install?h=v3.3.2
# http://git.alpinelinux.org/cgit/aports/tree/main/nginx-initscripts/nginx-initscripts.pre-install?h=v3.3.2
@ababushkin
Copy link
Copy Markdown

👍 thanks mate!

@lgescobar
Copy link
Copy Markdown

Thanks man!!

@bradmccormack
Copy link
Copy Markdown

Cheers !

@saadlu
Copy link
Copy Markdown

saadlu commented Jan 17, 2018

thx

@kolyadin
Copy link
Copy Markdown

kolyadin commented Jun 1, 2018

Thanks!

@yukal
Copy link
Copy Markdown

yukal commented Nov 19, 2018

Sometimes it needs to combine several independent processes that works in different containers. Don't forget to add nginx user to www-data group: apk --no-cache add shadow && usermod -aG www-data nginx

@max4ever
Copy link
Copy Markdown

create user www-data with id 1000
RUN adduser -S www-data -u 1000

@borkor
Copy link
Copy Markdown

borkor commented Aug 8, 2019

thanks, this did the job

@jyokyoku
Copy link
Copy Markdown

thanks!

@liviudobrea
Copy link
Copy Markdown

Cheers 🍺

@dalexhd
Copy link
Copy Markdown

dalexhd commented Apr 7, 2021

Thanks mate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment