Install older version of MongoDB with Docker - mongodb

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

Related

Is it possible to install postgresql 11 on Ubuntu 14.04?

I'm running on a Ubuntu 14,04 ('trusty') with no possibility to upgrade (a complex website-management platform is dependant upon it), but I'd like to install the latest version of postgresql in parallel... are there any compatibility issues?
Yes, I tried it just now, I followed the guide here: https://gist.github.com/alistairewj/8aaea0261fe4015333ddf8bed5fe91f8
# add postgresql to apt repository
sudo add-apt-repository 'deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main'
# get the signing key and update
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
# install postgresql
sudo apt-get install postgresql-11
# ensure that the server is started by switching to the postgres user
sudo su - postgres
# I didn't do this part since the database was started during install
# and I checked via `psql`
# /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main -l logfile start

Eclipse Che Google Cloud Compute Engine

Having challenges running Eclipse Che multiuser mode on Google Cloud computer engine instance.
Environment
(che cli): 6.1.0 - using docker 17.03.2-ce / native
Input:
docker run -it -e CHE_MULTIUSER=true -e CHE_HOST={server-ip} -v /var/run/docker.sock:/var/run/d
ocker.sock -v {localuserfolder}:/data eclipse/che start
Output:
INFO: (che start): Starting containers...
docker_compose --file="/data/instance/docker-compose-container.yml" -p="che" up -d >> "/data/cli.log" 2>&1
che_postgres_1 is up-to-date
ERROR: for che Container "4a245b40b556" is unhealthy.
ERROR: for keycloak Container "4a245b40b556" is unhealthy.
Encountered errors while bringing up the project.
ERROR: Error during 'compose up' - printing 30 line tail of {localuserfolder}/cli.log:
Noticed issue has something do to with postgres not having permission to run some scripts:
docker container logs che_postgres_1
/usr/bin/container-entrypoint: line 3: exec: /var/lib/pgsql/init-che-user-and-run.sh: cannot execute: Permission denied
/usr/bin/container-entrypoint: line 3: /var/lib/pgsql/init-che-user-and-run.sh: Permission denied
Documented fix doesn't work, :/data is already mounted to read/writable directory.
Probably Google Cloud overrides file system permissions somehow. Have you tried mounting different dirs into :/data?
I've tested your command and it works in my case by using a GCP instance with Debian 9 and docker 17.12, here is the steps that I've followed:
1) install docker
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common
$ curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable"
$ sudo apt-get install docker-ce
2) run che, I've used as a directory the /tmp, I recommend you to create another directory to store the files
$ sudo docker run -it -e CHE_MULTIUSER=true -e CHE_HOST=INTERNAL-IP -v /var/run/docker.sock:/var/run/docker.sock -v /DIRECTORY_WITH_PERMISSIONS:/data eclipse/che start

Unable to start mongodb using supervisor file

I've got a docker container, in which I'm installing mongo db. After installing,
I'm trying to start mongo and restore a mongo db dump. However, when I start the docker instance, I see that the user has been switched to root (as per supervisor instruction) but mongo is not started.
This is the supervisor snippet:
[supervisord]
nodaemon=true
[program:mongodb]
user=root
command=/usr/bin/mongod
This is my setup in the dockerfile:
RUN apt-get update && sudo apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
COPY supervisor.conf /etc/supervisor/conf.d/supervisor.conf
# Install MongoDB.
RUN \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && \
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen'
| tee /etc/apt/sources.list.d/mongodb.list && \
apt-get update && \
apt-get install -y mongodb-org && \
rm -rf /var/lib/apt/lists/*
# Define mountable directories.
VOLUME ["/data/db"]
# Define working directory.
WORKDIR /data
# Define default command.
CMD ["mongod"]
EXPOSE 27017
EXPOSE 28017
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
Am I missing any configuration setting? Any help is appreciated.
You're not able to run mongodb because while installing mongodb some files need authentication, so you just have to replace apt-get install -y mongodb-org with apt-get install -y --no-authentication mongodb-org and you'll be able to install mongodb without any problem.

Mapping a Volume in a docker

I am trying to map a Volume to the docker image using -v "/Users//data:/data/"
> docker run -p 27017:27017 --name mongo2_001 -d mongo -v "/Users/<user>/data:/data"
6cf25618d...
> docker ps -a
CONTAINER ID IMAGE COMMAND STATUS PORTS NAMES
6cf25618d.. mongo "/usr/bin/mongod -v /" Exited (1) mongoMG_001
It fails with the following error
> docker logs 6cf25618d..
2016-08-30T01:35:28.197+0000 F CONTROL [main] Failed global
initialization: BadValue: The "verbose" option string cannot
contain any characters other than "v"
When ran with out "-v ..." seems to work properly.
Not sure what could be wrong.
PS: Dockerfile used to create the image used above
FROM ubuntu:16.04
MAINTAINER Docker
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
RUN echo "deb http://repo.mongodb.org/apt/ubuntu $(cat /etc/lsb-release | grep DISTRIB_CODENAME | cut -d= -f2)/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
RUN apt-get update && apt-get install -y mongodb-org
RUN mkdir -p /data/db
WORKDIR /data
EXPOSE 27017
ENTRYPOINT ["/usr/bin/mongod"]
The order of "-v" parameter passed was incorrect.
Instead of going to docker command "-v" options it going to mongo container. Hence reorder the command as shown below
docker run -p 27018:27017 -v /Users/<user>/data:/data --name mongo2_001 -d mongo
On windows
docker run -p 27017:27017 -v /c/Users/<user>/data:/data --name mongo2_001 -d mongo
Mike Tung answer was not working for me. I was able to make it work with following command
docker run --name mongodb_win -v mongoWinData:/data/db -d -p 37017:27017 mongo

Docker Entrypoint for Postgres 9.3

This is my Dockerfile for installing Postgres.
# Set the base image to Ubuntu
FROM ubuntu:14.04
# Update the repository sources list
RUN apt-get update -y
################## BEGIN INSTALLATION ######################
# Install wget
RUN apt-get install wget -y
# Setup Postgres repository
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc
| sudo apt-key add -
# Add Postgres repository
RUN sh -c "echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list"
# Update repository
RUN apt-get update -y
# Install Postgres with Postgis
RUN apt-get install postgresql-9.3-postgis-2.1 -y
How can i add an Entrypoint for Postgres so that Postgres is automatically started in a Docker-container
My solution to start Postgres automatic:
RUN chmod +x /etc/init.d/postgresql
CMD service postgresql start && tail -F /var/lib/postgresql/data/serverlog
You can take ideas from the official docker-library/postgres Dockerfile:
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 5432
CMD ["postgres"]
They use a docker-entrypoint.sh script which will, at the end, launch postgres
exec gosu postgres "$#"