Skip to content

Commit

Permalink
Add home to mongodb user so that "mongosh" works again
Browse files Browse the repository at this point in the history
  • Loading branch information
yosifkit committed May 20, 2022
1 parent 1c55503 commit 090e563
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
12 changes: 9 additions & 3 deletions 4.0/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions 4.2/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions 4.4/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions 5.0/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions Dockerfile-linux.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
FROM {{ target.image }}

# 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 set -eux; \
groupadd --gid 999 --system mongodb; \
useradd --uid 999 --system --gid mongodb --home-dir /data/db mongodb; \
mkdir -p /data/db /data/configdb; \
chown -R mongodb:mongodb /data/db /data/configdb

RUN set -eux; \
apt-get update; \
Expand Down Expand Up @@ -107,10 +111,12 @@ RUN set -x \
&& rm -rf /var/lib/mongodb \
&& mv /etc/mongod.conf /etc/mongod.conf.orig

RUN mkdir -p /data/db /data/configdb \
&& chown -R mongodb:mongodb /data/db /data/configdb
VOLUME /data/db /data/configdb

# ensure that if running as custom user that "mongosh" has a valid "HOME"
# https://github.com/docker-library/mongo/issues/524
ENV HOME /data/db

COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["docker-entrypoint.sh"]

Expand Down

0 comments on commit 090e563

Please sign in to comment.