文件名称 | 说明 |
dockfile | docker镜像构建描述文件 |
start | ews镜像启动脚本 |
check | ews镜像健康检查脚本 |
制作memcached镜像的dockfile如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | FROM registry.acs.aliyun.com/open/centos: 3.0 . 0 RUN cd /acs/user && \ wget http: //memcached.org/files/memcached-1.4.22.tar.gz && \ tar -xzf memcached- 1.4 . 22 .tar.gz && \ rm -rf memcached- 1.4 . 22 .tar.gz && \ mv memcached- 1.4 . 22 memcached && \ cd memcached && \ ./configure --prefix /acs/user/memcached/ && \ make && make install && \ echo "export PATH=$PATH:/acs/user/memcached/bin/" > /root/.bash_profile && \ echo "export PATH=$PATH:/acs/user/memcached/bin/" > /acs/user/.bash_profile COPY check /acs/bin/check COPY start /acs/bin/start |
start脚本如下:
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 | #!/bin/bash env_file=/acs/conf/env.properties #read env if [ -f $env_file ];then port= "$(cat $env_file |grep -w port.mainport|awk -F " = " '{print $2}')" memory= "$(cat $env_file |grep -w memcached.memory|awk -F " = " '{print $2}')" connection= "$(cat $env_file |grep -w memcached.connection|awk -F " = " '{print $2}')" thread= "$(cat $env_file |grep -w memcached.thread|awk -F " = " '{print $2}')" fi #set default if [ -z "$port" ];then port= 11211 fi if [ -z "$memory" ];then memory= 500 fi if [ -z "$connection" ];then connection= 1024 fi if [ -z "$thread" ];then thread= 4 fi CMD= "/acs/user/memcached/memcached -u root -p $port -m $memory -c $connection -t $thread " #start memcached echo "################################### Start Memcached ###################################" echo "Start command : $CMD " $CMD & |
check脚本如下
1 2 3 4 5 6 7 8 | #!/bin/bash if [ "`ps aux|grep memcached|grep -v grep|wc -l`" -eq 0 ];then echo "failed" exit 1 fi echo "success" exit 0 |