Alexander Mills
Alexander Mills

Reputation: 100270

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...

Upvotes: 0

Views: 7555

Answers (1)

nickgryg
nickgryg

Reputation: 28733

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>

p.s. 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

Upvotes: 9

Related Questions