Docker中使用supervisor管理開機自啟動(redis && sshd)


1、Centos安裝Redis參考
http://blog.csdn.net/lsziri/article/details/69389187

2、Dockerfile
# Docker for CentOS 7

#Base image
FROM hfq/centos7:Jurassic

RUN \
wget http://download.redis.io/releases/redis-3.2.8.tar.gz && tar xzf redis-3.2.8.tar.gz \
&& cd redis-3.2.8 && yum -y install tcl && make && make install \
&& mkdir -p /etc/redis/

#安裝supervisor=============================重點=================================
RUN yum -y install python-setuptools
RUN easy_install supervisor

ADD redis.conf /etc/redis/redis.conf
ADD supervisord.conf /etc/supervisord.conf


EXPOSE 6379
EXPOSE 12007
CMD /usr/bin/supervisord -c /etc/supervisord.conf


###############################################構建腳本####################################
#構建image鏡像
#docker build -t hfq/centos7:IceAge .

#啟動container后台運行提供sshd服務
#docker run -d -P --name <container name> hfq/centos7:IceAge

#進入sshd啟動的container
#docker exec -it <container name or id> /bin/bash

#docker rm $(docker ps -a | grep "xxx/jedi:v5" | awk '{print $1}')

#操作記錄
#docker run -d -P --name hfq-jedi-smq-IceAge hfq/centos7:IceAge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
3、開啟啟動配置supervisord.conf
[supervisord]
nodaemon=true

[program:sshd]
command=/usr/sbin/sshd -D
autostart=true
autorestart=true

[program:redis]
command=/usr/local/bin/redis-server /etc/redis/redis.conf
————————————————
版權聲明:本文為CSDN博主「超級無敵強」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/lsziri/java/article/details/69396525


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM