简体   繁体   中英

Install older version of MongoDB with Docker

I have this:

docker run -d --name my-name mongo

Does anyone know how to run a specific version with Docker?

something like:

docker run -d --name my-name mongo=2.4.9

I need to run mongo with version 2.4.9...

You can install any mongodb version using mongodb repo.

The Dockerfile is:

FROM ubuntu

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
RUN apt-get update
RUN apt-get install -y mongodb-10gen=2.4.9 

EDIT:

You can also start mongodb container from an image with the exact version from their public docker hub repo.

Just choose the version that they have there:

curl -s https://registry.hub.docker.com/v1/repositories/mongo/tags | jq '.[] | (.name)' | awk -F'"' '{print $2}'

And start your mongodb docker container with the following command:

docker run -d --name my-name mongo:<version>

ps As far as we can see there are only following 2.4.x available versions of images on mongodb public docker hub repo:

 2.4 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM