Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declared volumes make deploying image as "pre-built" db extremely difficult #613

Closed
mshafer-NI opened this issue Mar 15, 2023 · 1 comment

Comments

@mshafer-NI
Copy link

High level

I'm trying to build a db into an image to deploy (read-only) in a k8s cluster. I need to be able to build it one environment and deploy in a completely different one.

Desired behavior

Ability to (within my Dockerfile):

  • start FROM mongo,
  • launch the db in background (can use tmux for this)
  • run script to populate db
  • stop db
  • commit as image

Blockers currently (/ other solutions if they would work)

  • Because these images declare volumes for /data/db,
    • Docker generates an ephemeral volume whenever a descendant image is launched.
    • Docker appears to not allow a client Dockerfile to "reset" volumes (like we can entrypoint and cmd),
  • Nor have I been able to figure out how to get mongod to store the initial db in a different folder.
@tianon
Copy link
Member

tianon commented Mar 15, 2023

The easiest workaround is to pass --dbpath to a different path, which all our scripts (and mongod itself) will honor:

mongo/docker-entrypoint.sh

Lines 224 to 228 in 2a7ebf4

if ! dbPath="$(_mongod_hack_get_arg_val --dbpath "$@")"; then
if _parse_config "$@"; then
dbPath="$(jq -r '.storage.dbPath // empty' "$jsonConfigFile")"
fi
fi

(Otherwise, this is a duplicate of #306)

@tianon tianon closed this as completed Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants