Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 3.6/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:xenial

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb

RUN set -eux; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion 4.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:xenial

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb

RUN set -eux; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion 4.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:bionic

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb

RUN set -eux; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion 4.4/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:bionic

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb

RUN set -eux; \
apt-get update; \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-linux.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM placeholder

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mongodb && useradd -r -g mongodb mongodb
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than creating a home directory for a system account, we should probably just set it somewhere that mongodb can write, like /tmp.

Like this:

Suggested change
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb
RUN groupadd -r mongodb && useradd --home-dir /tmp -r -g mongodb mongodb

Or this?
(fully expand the arguments for clarity; adjust now-edited RUN line to match semicolon formatting of other lines)

Suggested change
RUN groupadd -r mongodb && useradd -m -r -g mongodb mongodb
RUN set -eux; \
groupadd --system mongodb; \
useradd --system --gid mongodb --home-dir /tmp mongodb

Maybe even add --gid and --uid with explicit number 999 (the current value) like docker-library/postgres#93 to groupadd and useradd, respectively.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we just add ENV HOME /tmp so that any UID that the user runs as will work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a home-dir of /var/mongodb, similar to other system accounts?

> docker run mongo cut -d: -f 6,1 /etc/passwd | sort -t : -k 2
bin:/bin
proxy:/bin
sync:/bin
sys:/dev
mongodb:/home/mongodb
_apt:/nonexistent
nobody:/nonexistent
root:/root
games:/usr/games
daemon:/usr/sbin
backup:/var/backups
man:/var/cache/man
gnats:/var/lib/gnats
list:/var/list
mail:/var/mail
irc:/var/run/ircd
lp:/var/spool/lpd
news:/var/spool/news
uucp:/var/spool/uucp
www-data:/var/www

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to create the home directory to address the original issue.
The mongodb user ID should not share a global HOME env var with any other accounts.


RUN set -eux; \
apt-get update; \
Expand Down