Skip to content

Update mongosh version#31

Open
chinkung wants to merge 8 commits into
alpine-docker:masterfrom
chinkung:update-mongosh
Open

Update mongosh version#31
chinkung wants to merge 8 commits into
alpine-docker:masterfrom
chinkung:update-mongosh

Conversation

@chinkung
Copy link
Copy Markdown

@chinkung chinkung commented Nov 10, 2025

Upgrade the version of mongosh and all components of MongoDB Database Tools.

Note

The new version of mongosh is built with glibc, which is not natively supported by Alpine. You can work around this by using frolvlad/alpine-glibc base image, but it only supports amd64 and arm64.

mongodump version: 100.12.0
mongoexport version: 100.12.0
mongofiles version: 100.12.0
mongoimport version: 100.12.0
mongorestore version: 100.12.0
mongostat version: 100.12.0
mongotop version: 100.12.0
mongosh version: 2.5.9

@ozbillwang
Copy link
Copy Markdown
Contributor

ozbillwang commented Nov 10, 2025

Upgrade the version of mongosh and all components of MongoDB Database Tools.

Note

The new version of mongosh is built with glibc, which is not natively supported by Alpine. You can work around this by using frolvlad/alpine-glibc base image, but it only supports amd64 and arm64.

I like this PR — it no longer requires Node to be installed, which is great since Node tends to receive frequent CVEs.

But I never use the base image frolvlad/alpine-glibc , need review it first

@chinkung chinkung force-pushed the update-mongosh branch 2 times, most recently from 1bf8a7f to d7cb92a Compare November 10, 2025 11:37
@ozbillwang
Copy link
Copy Markdown
Contributor

but it only supports amd64 and arm64.

Supporting both amd64 and arm64 is sufficient.

@chinkung chinkung force-pushed the update-mongosh branch 13 times, most recently from bba4767 to 66b8516 Compare November 11, 2025 05:51
@ozbillwang
Copy link
Copy Markdown
Contributor

the final size has no big difference.

mongosh          latest   d90a2f80f4ba   19 hours ago    543MB
alpine/mongosh  latest    2d7a9cb13f43   2 years ago     559MB

@ozbillwang
Copy link
Copy Markdown
Contributor

ozbillwang commented Nov 11, 2025

I am considering building our own Alpine + glibc base image in the future.

Main reason is, the image (https://hub.docker.com/r/frolvlad/alpine-glibc/) doesn't mention anything about where it is built from (it's own Github or gitlab source code and automation cicd pipeline to check). It will be high risk to use this type of image as base images

@ozbillwang
Copy link
Copy Markdown
Contributor

ozbillwang commented Nov 11, 2025

ARG MONGOSH_VERSION=2.5.9

We also need adjust:

The version is not managed in Dockerfile directly.

  1. build with latest release (https://github.com/alpine-docker/multi-arch-docker-images/blob/master/functions.sh#L27-L29)
  2. run mongosh/version-tag.sh inside the container, two purposes: (1) to verify the proper version (2) the application can be run properly.
  3. create a new tag with this version
  4. push to hub.docker.com

@ozbillwang
Copy link
Copy Markdown
Contributor

Still need adjust.

  1. install with latest release first, we don't manage the version in Dockerfile directly.
  2. run version.sh to detect the version we installed, then create a new tag

I am considering building our own Alpine + glibc base image in the future.

Main reason is, the image (https://hub.docker.com/r/frolvlad/alpine-glibc/) doesn't mention anything about where it is built from (it's own Github or gitlab source code and automation cicd pipeline to check). It will be high risk to use this type of image as base images

Can we directly install glibc?

FROM alpine

# Install glibc
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
  wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-2.35-r1.apk && \
  apk add glibc-2.35-r1.apk

# Gnerate glibc locale
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-bin-2.35-r1.apk && \
  wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-i18n-2.35-r1.apk && \
  apk add glibc-bin-2.35-r1.apk glibc-i18n-2.35-r1.apk && \
  /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true && \
  echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
  apk del glibc-i18n

@chinkung
Copy link
Copy Markdown
Author

chinkung commented Nov 11, 2025

I am considering building our own Alpine + glibc base image in the future.

Main reason is, the image (https://hub.docker.com/r/frolvlad/alpine-glibc/) doesn't mention anything about where it is built from (it's own Github or gitlab source code and automation cicd pipeline to check). It will be high risk to use this type of image as base images

This is the source repository: https://github.com/Docker-Hub-frolvlad/docker-alpine-glibc. I use it because they keep the alpine version and glibc updated. They also utilize dependabot, so we shouldn't have to worry too much about vulnerabilities. Please take a look.

If after your review you still prefer to build from scratch, just let me know.

ARG MONGOSH_VERSION=2.5.9

We also need adjust:

The version is not managed in Dockerfile directly.

  1. build with latest release (https://github.com/alpine-docker/multi-arch-docker-images/blob/master/functions.sh#L27-L29)
  2. run mongosh/version-tag.sh inside the container, two purposes: (1) to verify the proper version (2) the application can be run properly.
  3. create a new tag with this version
  4. push to hub.docker.com

I will take a look at this

@chinkung
Copy link
Copy Markdown
Author

chinkung commented Nov 11, 2025

ARG MONGOSH_VERSION=2.5.9

We also need adjust:

The version is not managed in Dockerfile directly.

  1. build with latest release (https://github.com/alpine-docker/multi-arch-docker-images/blob/master/functions.sh#L27-L29)
  2. run mongosh/version-tag.sh inside the container, two purposes: (1) to verify the proper version (2) the application can be run properly.
  3. create a new tag with this version
  4. push to hub.docker.com

In the last 2 commit, I just

  • Update build.sh to accept another argument for fetching the latest version of the repo
  • Integrate the logic from build_asma.sh into build.sh
  • Mongosh will use the version specified in the VERSION argument

@chinkung
Copy link
Copy Markdown
Author

chinkung commented Nov 11, 2025

I am considering building our own Alpine + glibc base image in the future.
Main reason is, the image (https://hub.docker.com/r/frolvlad/alpine-glibc/) doesn't mention anything about where it is built from (it's own Github or gitlab source code and automation cicd pipeline to check). It will be high risk to use this type of image as base images

This is the source repository: https://github.com/Docker-Hub-frolvlad/docker-alpine-glibc. I use it because they keep the alpine version and glibc updated. They also utilize dependabot, so we shouldn't have to worry too much about vulnerabilities. Please take a look.

If after your review you still prefer to build from scratch, just let me know.

If you don't like the complexity of frolvlad/alpine-glibc, I have an simpler solution such as wolfi-base from Chainguard. It is built to support glibc right away, very compact, and use the apk package manager like Alpine.

I tested it and discovered it has a smaller footprint than frolvlad/alpine-glibc

I included this solution in the last 2 commit.

@chinkung chinkung changed the title Update mongosh version to 2.5.9 Update mongosh version Nov 11, 2025
@chinkung chinkung force-pushed the update-mongosh branch 2 times, most recently from 3b6bd4a to 72d60e5 Compare November 12, 2025 16:10
@ozbillwang
Copy link
Copy Markdown
Contributor

If you don't like the complexity of frolvlad/alpine-glibc, I have an simpler solution such as wolfi-base from Chainguard. It is built to support glibc right away, very compact, and use the apk package manager like Alpine.

I tested it and discovered it has a smaller footprint than frolvlad/alpine-glibc

I included this solution in the last 2 commit.

let's stick on Alpine based image

@chinkung
Copy link
Copy Markdown
Author

chinkung commented Nov 13, 2025

Still need adjust.

  1. install with latest release first, we don't manage the version in Dockerfile directly.
  2. run version.sh to detect the version we installed, then create a new tag

I am considering building our own Alpine + glibc base image in the future.
Main reason is, the image (https://hub.docker.com/r/frolvlad/alpine-glibc/) doesn't mention anything about where it is built from (it's own Github or gitlab source code and automation cicd pipeline to check). It will be high risk to use this type of image as base images

Can we directly install glibc?

FROM alpine

# Install glibc
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
  wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-2.35-r1.apk && \
  apk add glibc-2.35-r1.apk

# Gnerate glibc locale
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-bin-2.35-r1.apk && \
  wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-i18n-2.35-r1.apk && \
  apk add glibc-bin-2.35-r1.apk glibc-i18n-2.35-r1.apk && \
  /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true && \
  echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
  apk del glibc-i18n

This isn't functioning, and glibc 2.35 is also outdated.

If you truly want to continue with Alpine, can we use https://github.com/Docker-Hub-frolvlad/docker-alpine-glibc which currently running Alpine 3.22 and glibc 2.42 ?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants