I've a container with odoo on it on the dir "/opt/odoo/".
A init script on "/etc/init.d/odoo-server"
#!/bin/bash
### BEGIN INIT INFO
# Provides: odoo
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start openerp daemon at boot time
# Description: Enable service provided by daemon.
# X-Interactive: true
### END INIT INFO
## more info: http://wiki.debian.org/LSBInitScripts
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DAEMON=/opt/odoo/openerp-server
NAME=odoo
DESC=odoo
CONFIG=/etc/odoo-server.conf
LOGFILE=/var/log/odoo/odoo-server.log
PIDFILE=/var/run/${NAME}.pid
USER=odoo
export LOGNAME=$USER
test -x $DAEMON || exit 0
set -e
function _start() {
start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER:$USER --background --make-pidfile --exec $DAEMON -- --config $CONFIG --logfile $LOGFILE
}
function _stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE --oknodo --retry 3
rm -f $PIDFILE
}
function _status() {
start-stop-daemon --status --quiet --pidfile $PIDFILE
return $?
}
case "$1" in
start)
echo -n "Starting $DESC: "
_start
echo "ok"
;;
stop)
echo -n "Stopping $DESC: "
_stop
echo "ok"
;;
restart|force-reload)
echo -n "Restarting $DESC: "
_stop
sleep 1
_start
echo "ok"
;;
status)
echo -n "Status of $DESC: "
_status && echo "running" || echo "stopped"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0
then I do
root@cca438c81a87:/# update-rc.d odoo-server defaults
Adding system startup for /etc/init.d/odoo-server ...
/etc/rc0.d/K20odoo-server -> ../init.d/odoo-server
/etc/rc1.d/K20odoo-server -> ../init.d/odoo-server
/etc/rc6.d/K20odoo-server -> ../init.d/odoo-server
/etc/rc2.d/S20odoo-server -> ../init.d/odoo-server
/etc/rc3.d/S20odoo-server -> ../init.d/odoo-server
/etc/rc4.d/S20odoo-server -> ../init.d/odoo-server
/etc/rc5.d/S20odoo-server -> ../init.d/odoo-server
When I start the docker with docker start the odoo-server doesn't start, when I run inside the docker /etc/init.d/odoo-server start it work ok...
what is happening?
If you would like to keep your container running in detached mode, you need to run something in the foreground. An easy way to do this is to tail the /dev/null device as the CMD or ENTRYPOINT command of your Docker image. This command could also run as the last step in a custom script used with CMD or ENTRYPOINT.
To run docker inside docker, all you have to do it just run docker with the default Unix socket docker. sock as a volume. Just a word of caution: If your container gets access to docker. sock , it means it has more privileges over your docker daemon.
Docker containers typically do not have a functioning init system. If you are simply running a single service -- just start that.
If you need something more complex, look at supervisord or runit.
Containers are not virtual machines.
If you're looking for a Docker image that behaves much like a full blown VM with init system, take a look at phusion baseimage
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With