制作xnetd镜像
制作its-xnetd:1.0
镜像
ps:xnetd 是我公司的一个自主研发的消息中间件,可以理解为 mq,本文介绍,如何将公司独有的组建放入Docker,制作成镜像。
一、前提说明
1)首先要有xnetd的应用,然后和Dockerfile在同级目录,详情如下:
|- Dockerfile
|- xnetd_bin
\- start.sh ## 启动xnetd的脚本
\- .config ## xnetd相关的配置
\- xnetd ## xnetd应用
2) .config 配置
[sds]
Level=5
OnlineCheckSecond=100
OnlineEchoSecond=2
LocalTitle=echo;all
LocalGroup=g1
AutoDisconnect=1
cloud=none
;InitTerm=100
AlwaysAuto=1
CutLength=300
DispLevel=5
LogPath=/root/logs/xnetd
[eops]
Level=5
OnlineCheckSecond=100
OnlineEchoSecond=2
LocalTitle=echo;all
LocalGroup=g1
AutoDisconnect=1
cloud=none
;InitTerm=100
AlwaysAuto=1
CutLength=300
DispLevel=5
LogPath=/root/logs/eops/xnetd
start.sh 配置
/usr/xnetd_bin/xnetd sds 17300
sleep 2
/usr/xnetd_bin/xnetd eops 13300
sleep 2
二、开始制作镜像<font color="red" size="4">(3步)</font>
1)、编写Dockerfile文件
FROM centos:7.4.1708
MAINTAINER Will wangzhenwei@erayt.com
#上传安装xnetd
RUN mkdir /usr/xnetd_bin
COPY xnetd_bin/xnetd /usr/xnetd_bin/xnetd
COPY xnetd_bin/start.sh /usr/xnetd_bin/start.sh
COPY xnetd_bin/.config /root/.config
RUN mkdir -p /root/logs/eops/xnetd
RUN mkdir /root/logs/xnetd
##开启端口
EXPOSE 13300 17300
#CMD ["/usr/xnetd_bin/start.sh" , "run"]
CMD sh /usr/xnetd_bin/start.sh && tail -f /root/.config
2)、执行build 命令
docker build --rm=true --no-cache=false -t its-xnetd:1.0 .
3)、启动容器
docker run -it -d --name=xnetd -p 13300:13300 -p 17300:17300 its-xnetd:1.0
<font color="red" size="4">创建完成</font>
三、日志记录
[root@helloword xnetd]# docker build --rm=true --no-cache=false -t its-xnetd:1.0 .
Sending build context to Docker daemon 1.168MB
Step 1/10 : FROM centos:7.4.1708
---> 3afd47092a0e
Step 2/10 : MAINTAINER Will wangzhenwei@erayt.com
---> Using cache
---> 50450d3a273b
Step 3/10 : RUN mkdir /usr/xnetd_bin
---> Running in 584ed0248fd7
---> 6607c76ffc46
Removing intermediate container 584ed0248fd7
Step 4/10 : COPY xnetd_bin/xnetd /usr/xnetd_bin/xnetd
---> 5e7eb427b545
Step 5/10 : COPY xnetd_bin/start.sh /usr/xnetd_bin/start.sh
---> 1bfe9cd23270
Step 6/10 : COPY xnetd_bin/.config /root/.config
---> 706607e875ee
Step 7/10 : RUN mkdir -p /root/logs/eops/xnetd
---> Running in 87b62ed416a8
---> 3b0a05d932ed
Removing intermediate container 87b62ed416a8
Step 8/10 : RUN mkdir /root/logs/xnetd
---> Running in ae25536eb944
---> ceb1c31910cf
Removing intermediate container ae25536eb944
Step 9/10 : EXPOSE 13300 17300
---> Running in 02750787bf3f
---> 0e559c595bb1
Removing intermediate container 02750787bf3f
Step 10/10 : CMD sh /usr/xnetd_bin/start.sh && tail -f /root/.config
---> Running in b7bfad96acd7
---> 1bc3630a75d4
Removing intermediate container b7bfad96acd7
Successfully built 1bc3630a75d4
Successfully tagged xnetd:latest
[root@helloword xnetd]# docker run -it -d --name=xnetd -p 13300:13300 -p 17300:17300 its-xnetd:1.0
2aa96230ecd3e68d86ec659307c61d1c22001aa2e65a508b96c6d781ed8a477d
[root@helloword xnetd]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2aa96230ecd3 its-xnetd:1.0 "/bin/sh -c 'sh /u..." 2 seconds ago Up 1 second 0.0.0.0:13300->13300/tcp, 0.0.0.0:17300->17300/tcp xnetd
网友评论