linux下docker添加一些自启动命令去自启动服务
一、创建容器时运行包含自启动路径的命令docker run -p 80:80 -i -t -d --restart=always ubuntu:18.04 /bin/bash -c "/etc/rc.local; /bin/bash"然后:二、所有想在开机执行的命令都可以写在里面自启动vim /etc/rc.localexit上面新增service apache2 s...
·
一、创建容器时运行包含自启动路径的命令
docker run -p 80:80 -i -t -d --restart=always ubuntu:18.04 /bin/bash -c "/etc/rc.local; /bin/bash"
然后:
二、所有想在开机执行的命令都可以写在里面
自启动
vim /etc/rc.local
exit上面新增
service apache2 start
service mysql start
最后大概这个样子
#!/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 apache2 start
service mysql start
exit 0
记得要赋予文件可执行权限
chmod 777 /etc/rc.local
更多推荐
已为社区贡献4条内容
所有评论(0)