Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker uses supervisor to start MongoDB

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Docker in the study of continuous improvement, continuous learning, some of the original methods are optimized.

Image download address:

Old solution address: if it is immature, it is not uploaded.

New solution address: https://github.com/aarongo/centos-mongodb-supervisor.git

1. Old scheme (tried many times to install MongoDB with centos, but all failed, and finally installed MongoDB with ubuntu and started successfully)

Dockerfile:

FROM ubuntu:12.04MAINTAINER aaron "aaron.docker@gmail.com" RUN apt-key adv-keyserver hkp://keyserver.ubuntu.com:80-recv 7F0CEB10 & &\ echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > / etc/apt/sources.list.d/mongodb.list & &\ apt-get update & &\ apt-get install-y mongodb-org & &\ rm-rf / var/ Lib/apt/lists/*VOLUME ["/ data/db"] CMD ["mongod"] EXPOSE 27017EXPOSE 28017

Mode of operation:

Docker run-d-p 27017pur27017-v localdir:/data/db-- name mongodb aarongo/ubuntu-mongodb#-v option to mount the directory in the host to the container

Run the test:

The biggest disadvantage of this method is that the MongoDB cannot be managed in real time when the mirror is running and multiple service processes cannot be started at the same time.

two。 New scheme (use centos to install MongoDB and configure ssh so that when the image starts, the application supervisor starts ssh and MongoDB at the same time)

Dockerfile: (based on the previously built centos-ssh-supervisor image)

FROM aarongo/centos-ssh-supervisor:latestMAINTAINER aaron "aaron.docker@gmail.com" # Install mongodbRUN yum-y install wget & & yum-y install tar &\ wget http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.6.4.tgz & &\ tar xzvf mongodb-linux-x86_64-2.6.4.tgz &\ mv mongodb-linux-x86_64-2.6.4 / / mongodb & &\ mkdir-p / data/dbCOPY supervisord.conf / etc/supervisord.confVOLUME ["/ data/db"] EXPOSE 22 27017 28017CMD ["/ usr/bin/supervisord"]

Mode of operation:

Docker run-p 1026 hostdir:/data/db aarongo/centos-mongodb-supervisor 22-p 27017 hostdir:/data/db aarongo/centos-mongodb-supervisor 27017-p 28017 hostdir:/data/db aarongo/centos-mongodb-supervisor

Run the test:

This method perfectly solves the problem that multiple services cannot be started by a single container, and can manage images in real time.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report