rc.local 里 写着你要执行启动的那些服务,开始只是加了启动的服务,启动完就退出了,后来往rc.local里加了/bin/bash才在后台正常运行,第一次run是直接进入docker里, 退出之后, 执行docker ps -a 会看到CONTAINER ID, 之后只要docker start CONTAINER ID ,启动之后docker CONTAINER 会在后台运行, docker attch CONTAINER ID 进入容器可以看到正在运行的服务(当然是还服务多还没有执行完的时候)
dcoker 容器里,我的 rc.local是
===========================
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
service mysql start &
sleep 5
service memcached start &
sleep 5
service redis-server start &
sleep 5
service rabbitmq-server start &
sleep 5
service nginx start &
sleep 5
mongod -f /etc/mongodb.conf &
sleep 5
service elasticsearch start &
sleep 5
/etc/init.d/ssh start &
sleep 5
/bin/bash
这是我的ubuntu /etc/rc.local
===========================
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.