title: Mongodb on debian docker image - unable to stand
body: <p>Good evening.
  I'm noobie in docker and try to learn it a little bit. Currently writing simple java application integrated with mongodb, but I stuck on dockerfile. Basically the problem is with mongodb start. Here is my docker file:</p>
  
  <pre><code>FROM  debian:buster-slim
  
  # Install necessary libs
  RUN apt-get update &amp;&amp; apt-get install -y apt-utils wget gnupg gnupg2 curl
  
  # Install mongodb
  RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
  RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
  RUN apt-get update
  RUN apt-get install -y mongodb-org
  RUN systemctl enable mongod.service
  RUN service mongod start
  
  # Install jre 11
  RUN apt-get install -y openjdk-11-jre
  </code></pre>
  
  <p>Here is the terminal output (only last step):</p>
  
  <pre><code>Setting up mongodb-org-shell (4.2.1) ...
  Setting up mongodb-org-tools (4.2.1) ...
  Setting up mongodb-org-mongos (4.2.1) ...
  Setting up mongodb-org (4.2.1) ...
  Removing intermediate container 7491080bfe9f
   ---&gt; bbcf5b2ccb13
  Step 7/11 : RUN service mongod start
   ---&gt; Running in 46a66989ade2
  mongod: unrecognized service
  The command '/bin/sh -c service mongod start' returned a non-zero code: 1
  </code></pre>
  
  <p>Funny think is that I followed an official mongodb installation guide:
  <a href="https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/" rel="nofollow noreferrer">Mongodb installation on debian</a></p>
  
  <p>During installation on 'real' debian/ubuntu machine it works.
  It also doesn't work when tried to build docker image from official mongodb image from docker hub, I mean <code>FROM mongo:4.2-bionic</code></p>
  
  <p>After login to container and try to run <code>mongo</code> it returns:</p>
  
  <pre><code>root@8cc1d270a262:~# mongo
  MongoDB shell version v4.2.0
  connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&amp;gssapiServiceName=mongodb
  2019-10-23T20:39:44.728+0000 E  QUERY    [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
  connect@src/mongo/shell/mongo.js:341:17
  @(connect):2:6
  2019-10-23T20:39:44.729+0000 F  -        [main] exception: connect failed
  2019-10-23T20:39:44.729+0000 E  -        [main] exiting with code 1
  </code></pre>
  
  <p>I expected that, cause mongo is unable to stand... Somehow.</p>
  
  <p>Any ideas?</p>