Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing mongodb in a docker container

I am trying to create a docker image for mongodb. I am followed the installation instructions from the official mongodb installation to the letter without success. I have tried every single blog and installation instruction out there but without any success. Any help will be greatly appreciated.

My dockerfile contents :

FROM ubuntu:16.04
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
RUN echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu/ xenial/mongodb-org/3.4 multiverse" |  tee /etc/apt/sources.list.d/mongodb-3.4.list

RUN apt-get update && apt-get install -y mongodb-org
RUN mkdir -p /data/db
RUN chown -R mongodb:mongodb /data/db
ADD mongodb.conf /etc/mongodb.conf
ADD mongodb.pem /etc/ssl/certs/mongodb.pem

VOLUME ["/data/db"]
EXPOSE 27017
ENTRYPOINT ["/usr/bin/mongod", "--config", "/etc/mongodb.conf"]

I am using the follwing command :

sudo docker image build -t mongodb .

Everytime I am trying to build the image, I get the following:

Sending build context to Docker daemon   7.68kB
Step 1/11 : FROM ubuntu:16.04
 ---> 14f60031763d
Step 2/11 : RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
 ---> Using cache
 ---> 97a851663e60
Step 3/11 : RUN echo "deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu/ xenial/mongodb-org/3.4 multiverse" |  tee /etc/apt/sources.list.d/mongodb-3.4.list
 ---> Using cache
 ---> 122a2fad0021
Step 4/11 : RUN apt-get update && apt-get install -y mongodb-org
 ---> Running in 014e7918e156
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Ign:2 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 InRelease
Get:3 http://archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:5 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Get:6 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release [3457 B]
Get:7 http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Release.gpg [801 B]
Get:8 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [42.0 kB]
Get:9 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [394 kB]
Get:10 http://security.ubuntu.com/ubuntu xenial-security/restricted amd64 Packages [12.8 kB]
Get:11 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [184 kB]
Get:12 http://security.ubuntu.com/ubuntu xenial-security/multiverse amd64 Packages [2931 B]
Get:13 http://archive.ubuntu.com/ubuntu xenial/universe Sources [9802 kB]
Get:14 http://alert.scansafe.net/alert/process?a=-3-BW4R_eLtf_R7PUTnlOeb6kHjw5kMPDH4n_j9vuji99G7a0CHJtXpeYpzGHZPC0wRr52uECxiceRo23F5y5nJqQ&b=iDw6Hli7TPC7hodjxRcdBj9i1UevoPI4aXCTkM2htEe16EENN3K7sUkicBLWMmbvQJHy5RccSqbLlHU4Q23W8w7vzekV399jAw6NbyJsJBJPm_U3VdYSosJyHFldLABeOaw16L56ass0uQ-KDLgyWadENbyoiMwzO-1nwE6QYwf1NcLI1073TBf9mObvKXGE7lL2-OpA1MA6dI2cdh6AETyP3g0OipJUm4fag2-7TI5j_BImQOsvvEVlzZ7ilSFaUVOlMbWBWuuU822y_f0ph82C3dG_kBenckmPWso5ln9ShKoiCmjbcSZjT76_j3Hwh3nSYYv1AqX8Kj8gFD4k1MI2Li7WNMs9rnq4vUa9eeaN_ivffMClQHK6I88vPaR4FQr61U5ecOwl0KmVyhP3FLDF-4KpOGg3Kf7kVRCnLpQZwXnsrrTt3enSpjn66IzlCgG3PmNrVhdqOTBQFh5PfWtgdGG68Ir6hZIBt170nqGSMhgFmlTMTMbO5EGkA-uyPz8worv7RSc&blockedUrl=http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages [5870 B]
Err:14 http://alert.scansafe.net/alert/process?a=-3-BW4R_eLtf_R7PUTnlOeb6kHjw5kMPDH4n_j9vuji99G7a0CHJtXpeYpzGHZPC0wRr52uECxiceRo23F5y5nJqQ&b=iDw6Hli7TPC7hodjxRcdBj9i1UevoPI4aXCTkM2htEe16EENN3K7sUkicBLWMmbvQJHy5RccSqbLlHU4Q23W8w7vzekV399jAw6NbyJsJBJPm_U3VdYSosJyHFldLABeOaw16L56ass0uQ-KDLgyWadENbyoiMwzO-1nwE6QYwf1NcLI1073TBf9mObvKXGE7lL2-OpA1MA6dI2cdh6AETyP3g0OipJUm4fag2-7TI5j_BImQOsvvEVlzZ7ilSFaUVOlMbWBWuuU822y_f0ph82C3dG_kBenckmPWso5ln9ShKoiCmjbcSZjT76_j3Hwh3nSYYv1AqX8Kj8gFD4k1MI2Li7WNMs9rnq4vUa9eeaN_ivffMClQHK6I88vPaR4FQr61U5ecOwl0KmVyhP3FLDF-4KpOGg3Kf7kVRCnLpQZwXnsrrTt3enSpjn66IzlCgG3PmNrVhdqOTBQFh5PfWtgdGG68Ir6hZIBt170nqGSMhgFmlTMTMbO5EGkA-uyPz8worv7RSc&blockedUrl=http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4/multiverse amd64 Packages
  Hash Sum mismatch
Get:15 http://archive.ubuntu.com/ubuntu xenial/main amd64 Packages [1558 kB]
Get:16 http://archive.ubuntu.com/ubuntu xenial/restricted amd64 Packages [14.1 kB]
Get:17 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages [9827 kB]
Get:18 http://archive.ubuntu.com/ubuntu xenial/multiverse amd64 Packages [176 kB]
Get:19 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [208 kB]
Get:20 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [756 kB]
Get:21 http://archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [13.3 kB]
Get:22 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [645 kB]
Get:23 http://archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [17.5 kB]
Get:24 http://archive.ubuntu.com/ubuntu xenial-backports/main amd64 Packages [4930 B]
Get:25 http://archive.ubuntu.com/ubuntu xenial-backports/universe amd64 Packages [6237 B]
Fetched 24.2 MB in 7s (3158 kB/s)
Reading package lists...
E: Failed to fetch http://alert.scansafe.net/alert/process?a=-3-BW4R_eLtf_R7PUTnlOeb6kHjw5kMPDH4n_j9vuji99G7a0CHJtXpeYpzGHZPC0wRr52uECxiceRo23F5y5nJqQ&b=iDw6Hli7TPC7hodjxRcdBj9i1UevoPI4aXCTkM2htEe16EENN3K7sUkicBLWMmbvQJHy5RccSqbLlHU4Q23W8w7vzekV399jAw6NbyJsJBJPm_U3VdYSosJyHFldLABeOaw16L56ass0uQ-KDLgyWadENbyoiMwzO-1nwE6QYwf1NcLI1073TBf9mObvKXGE7lL2-OpA1MA6dI2cdh6AETyP3g0OipJUm4fag2-7TI5j_BImQOsvvEVlzZ7ilSFaUVOlMbWBWuuU822y_f0ph82C3dG_kBenckmPWso5ln9ShKoiCmjbcSZjT76_j3Hwh3nSYYv1AqX8Kj8gFD4k1MI2Li7WNMs9rnq4vUa9eeaN_ivffMClQHK6I88vPaR4FQr61U5ecOwl0KmVyhP3FLDF-4KpOGg3Kf7kVRCnLpQZwXnsrrTt3enSpjn66IzlCgG3PmNrVhdqOTBQFh5PfWtgdGG68Ir6hZIBt170nqGSMhgFmlTMTMbO5EGkA-uyPz8worv7RSc&blockedUrl=http://repo.mongodb.org/apt/ubuntu/dists/xenial/mongodb-org/3.4/multiverse/binary-amd64/Packages.gz     Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c apt-get update && apt-get install -y mongodb-org' returned a non-zero code: 100
like image 421
fitims Avatar asked Oct 17 '22 08:10

fitims


2 Answers

The line RUN apt-get update && apt-get install -y mongodb-org should be RUN apt-get update && apt-get install -y mongodb You can also just use the official mongo image and then provide a docker link

like image 173
Mike Tung Avatar answered Oct 19 '22 21:10

Mike Tung


I'm hoping you know that you don't have to go to the effort because there is already an official image on Docker Hub.

However, your error message gives a hint to what went wrong:

mongodb-org/3.4/multiverse/binary-amd64/Packages.gz Hash Sum mismatch

You can correct this if you are determined to make your own image.

One place I would start is looking at the Docker best practices for run. You have split some related to the same dependency over multiple lines in your code, which can cause caching to mismatch versions and hashes. This is likely the problem.

If you aren't satisfied with using the official image directly you can at least look at how it was built here: https://github.com/docker-library/mongo/blob/c02ca4cce8c69e5069b75cb574d1b99d7b4edaeb/3.4/Dockerfile

like image 22
Archernar Avatar answered Oct 19 '22 20:10

Archernar