saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.09k stars 5.47k forks source link

salt-minion can't start using upstart in docker container(ubuntu:raring) #11118

Closed tallmad closed 10 years ago

tallmad commented 10 years ago

Salt-minion can start normally using command "salt-minion", but it can't start using "service salt-minion start" in docker container(docker official image ubuntu:raring)

kiorky commented 10 years ago

tha's normal as docker wont support upstart unless you hack you own image.

kiorky commented 10 years ago

see dotcloud/docker#2276

tallmad commented 10 years ago

@kiorky I installed redis-server, and started redis-server using 'service redis-server start' and the redis was started and worked well

kiorky commented 10 years ago

ps aux|grep init (from the container)

kiorky commented 10 years ago

The issue which your redis server starting is that you are certainly using one of those dumb base images which diverts initctl to /dev/null or /bin/true, so you though your service was started, but in fact, the redis was not started using the service command but by apt itself during installation. And yes, diverting init systems to /bin/true is more that an evil that a workaround :)

Just restart your container and i think your redis server wont be up as well :)

/cc @techhat as we discussed late this WE ^^.

kiorky commented 10 years ago

/cc @regilero

kiorky commented 10 years ago

Looking at redis-server packaging, in fact redis-server does not use upstart but an old init script

#! /bin/sh
### BEGIN INIT INFO
# Provides:     redis-server
# Required-Start:   $syslog
# Required-Stop:    $syslog
# Should-Start:     $local_fs
# Should-Stop:      $local_fs
# Default-Start:    2 3 4 5
# Default-Stop:     0 1 6
# Short-Description:    redis-server - Persistent key-value db
# Description:      redis-server - Persistent key-value db
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/redis-server
DAEMON_ARGS=/etc/redis/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis.pid

test -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0

set -e

case "$1" in
  start)
    echo -n "Starting $DESC: "
    touch $PIDFILE
    chown redis:redis $PIDFILE
    if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
    then
        echo "$NAME."
    else
        echo "failed"
    fi
    ;;
  stop)
    echo -n "Stopping $DESC: "
    if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
    then
        echo "$NAME."
    else
        echo "failed"
    fi
    rm -f $PIDFILE
    ;;

  restart|force-reload)
    ${0} stop
    ${0} start
    ;;
  *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

That's why redis-server start correctly when you invoke service start, it does not use upstart.

kiorky commented 10 years ago

So to try to sum up:

In the case of salt-minion, on ubuntu the packaging uses an upstart job and no classical init script so it is normal that it wont start in both cases.

tallmad commented 10 years ago

very thanks for your detailed explanation !!! I'll close the issue.