3cola / docker-mongo

MongoDB Docker Image, with mongodb, run from supervisor, auto backup
MIT License
0 stars 0 forks source link

Help with docker-alpine-mongo #1

Open nevf opened 8 years ago

nevf commented 8 years ago

@3cola Thanks for your work on https://github.com/3cola/docker-alpine-mongo The Issues tracker is not available there and this was the only way I found to contact you.

I'm trying to use https://github.com/3cola/docker-alpine-mongo via. supervisor and wonder if you can help me with the supervisor.conf entry. I've tried command = /run mongod --directoryperdb --journal but that doesn't work. I'm new to docker and supervisor.

Also could you please enable "Issues' on the other repo. Thanks.

3cola commented 8 years ago

Hello

Every ways to contact me are goods ! :)

Huum this docker project is in early stages but I think that I managed to have a running mongo at least once... Maybe the documentation is not explicit enough, I should work on this.

Unfortunately I am in the mountains for the day. Can you please try to describe more what you want to do and I will take a look in the evening and I will try to help you the most I can.

Cheers.

On April 21, 2016 11:10:17 AM GMT+02:00, Neville Franks notifications@github.com wrote:

@3cola Thanks for your work on https://github.com/3cola/docker-alpine-mongo The Issues tracker is not available there and this was the only way I found to contact you.

I'm trying to use https://github.com/3cola/docker-alpine-mongo via. supervisor and wonder if you can help me with the supervisor.conf entry. I've tried command = /run mongod --directoryperdb --journal but that doesn't work. I'm new to docker and supervisor.

Also could you please enable "Issues' on the other repo. Thanks.


You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/3cola/docker-mongo/issues/1

Etienne Colaitis

nevf commented 8 years ago

@3cola Thanks for the quick reply. I've created a docker base image with alpine:edge, node.js, mongodb using your run script and supervisor.

You can get it using: docker pull nevf/mnsbase

The Dockerfile is:

From alpine:edge

ADD run /

RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
  apk update && apk upgrade  \
  && apk add nodejs \
  && npm uninstall -g npm \
  && apk add --no-cache mongodb \
  && apk add python py-pip \
  && pip install supervisor \
  && rm -rf /var/cache/apk/*

COPY supervisord.conf /etc/supervisord.conf

# Mongodb stuff
# VOLUME /data/db
EXPOSE 27017 28017

supervisord.conf is:

[supervisord]
nodaemon=true

[include]
files = /etc/supervisor/conf.d/*.conf

So when supervisor starts it runs all of the *.conf files.

Then I have another image whose Dockerfile is:

FROM nevf/mnsbase

COPY clibu.sv.conf /etc/supervisor/conf.d/clibu.sv.conf

... copy other app files

VOLUME /data/db

ENTRYPOINT ["supervisord", "--nodaemon", "--configuration", "/etc/supervisord.conf"]

And the clibu.sv.conf is where I'm having trouble starting mongod.

[supervisord]
nodaemon=true
loglevel=debug

[program:mongo]
command = /run mongod --directoryperdb --journal

[program:node]
command = node app.js

Thanks again, and enjoy the mountains (what country?) Neville

3cola commented 8 years ago

Hello,

So, there is different things here... 3cola/docker-mongo is a docker image I started on top of an ubuntu to try to manage mongodb from supervisor. 3cola/docker-alpine-mongo is a docker image on top of alpine linux where I tried to do a minimal install of mongodb. The run script with this image is only to be able to pass other commands than starting the db, or arguments to mongod when running a container. You should not use it if you plan to make use of supervisor (as supervisor will do the work of starting everything you need). All the arguments you want to use to start mongodb, you should put them into the supervisor conf file.

you supervisord.conf should look like this :

[supervisord]
nodaemon=true
loglevel=debug
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
childlogdir=/var/log/supervisor

[program:mongo]
user=mongodb
directory=/data/db
command=/usr/bin/mongod --config=/etc/mongod.conf
autostart=true
autorestart=true

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)

and a mongod conf file :

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

storage:
  journal:
    enabled: true

#  engine:
#  mmapv1:
#  wiredTiger:

#systemLog:

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1

My goal is at some point to merge those two into one image that will be running from alpine linux, with supervisor starting mongodb and a cronjob to do backups of the mongodb regularly. As I haven't done the work yet and as I am on vacations in Mallorca for the weeks, hiking in sierra tramuntana, I cannot really help you. But I will share with you my sources of inspiration for this task.

I have also one repository 3cola/docker-alpine-mongo forked from another guy, on which I am working on making work a nodejs on top of alpine linux. The goal is to make work a meteor server on this node. This task is not finished also.

When I will manage to make work both images above (alpine mongo on supervisor with cron job backup and alpine nodejs on supervisor), I will attempt to make one image with alpine+supervisor+mongodb+autobackup cron job+nodejs for meteor so I will have a full meteor ready db+appserver for small apps and POCs for some of my clients.

Here is the html links I am reading for inspiration in these tasks : https://docs.docker.com/engine/userguide/ https://docs.docker.com/engine/admin/using_supervisord/ https://serversforhackers.com/monitoring-processes-with-supervisord https://gist.github.com/martinrusev/7015e393d46647dbad15 https://docs.mongodb.org/manual/tutorial/backup-and-restore-tools/ https://leoengine.org/getting-start-with-docker-and-mongo/ https://hub.docker.com/r/mhart/alpine-node/

nevf commented 8 years ago

@3cola Thanks for the detailed reply. We're have a 3 day long weekend here in Australia which has been very busy so apologies for not replying earlier. I've decided to have a single container which includes Alpine Linux, Mongo and Node and then another container I build from that with my Node app code. I'm starting Mongo from within the Node app which I need to do to create the initial Admin user anywhere. Well it is easier that way.

I'll probably use forever or pm2 to keep everything running. This also lets me have a slightly smaller image than if I was using supervisor which is a good.

I'll keep an eye on your work and let you know when I have my final app up on Docker Hub in case you want to try it. We're heading to Europe in 3 weeks so a lot to do before then.

Thanks again for your efforts.