redhat 镜像_Docker进阶---制作MQ镜像

为了展示制作镜像的各个步骤,可以分为两大步骤:先制作一个安装了MQ的镜像,然后在此基础上制作一个创建了各种MQ对象的镜像。

1. 制作安装了MQ 的 Docker 镜像

(1)准备安装资源

安装包:

[root@centos1 mq]# ls -rlttotal 389160-rw-r--r--. 1 root root 398496617 Sep 23 2016 ToprowMQ_8.0.0.3_Linux_X86_64_Full.tar.gz[root@centos1 mq]# tar -xvf ToprowMQ_8.0.0.3_Linux_X86_64_Full.tar.gz [root@centos1 mq]# echo $PWD/tool/mq

镜像:

[root@centos1 mq]# docker image ls centosREPOSITORY TAG IMAGE ID CREATED SIZEcentos latest 9f38484d220f 7 weeks ago 202MB

(2)启动容器

映射本地目录到容器:

[root@centos1 mq]# docker run -it -v $PWD:/tmp/software centos /bin/bash[root@6dfcd9f0360c /]# uname -aLinux 6dfcd9f0360c 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux[root@6dfcd9f0360c /]# [root@6dfcd9f0360c /]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@6dfcd9f0360c /]# [root@6dfcd9f0360c /]# ls -ld /tmp/software/drwxr-xr-x. 7 root root 4096 May 8 08:26 /tmp/software/[root@6dfcd9f0360c /]# [root@6dfcd9f0360c /]# ls -l /tmp/software/ total 679608drwxrwxr-x. 3 500 500 18 Sep 21 2016 PreReqsdrwxrwxr-x. 2 500 500 4096 Sep 21 2016 READMES-rw-rw-r--. 1 500 500 2390555 Sep 21 2016 ToprowMQClient-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 150269181 Sep 21 2016 ToprowMQExplorer-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 98662028 Sep 21 2016 ToprowMQJRE-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 17627124 Sep 21 2016 ToprowMQJava-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 140705 Sep 21 2016 ToprowMQMsg_Zh_CN-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 142090 Sep 21 2016 ToprowMQMsg_Zh_TW-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 10921932 Sep 21 2016 ToprowMQRuntime-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 232177 Sep 21 2016 ToprowMQSDK-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 669005 Sep 21 2016 ToprowMQSamples-8.0.0-3.x86_64.rpm-rw-rw-r--. 1 500 500 16310368 Sep 21 2016 ToprowMQServer-8.0.0-3.x86_64.rpm-rw-r--r--. 1 root root 398496617 Sep 23 2016 ToprowMQ_8.0.0.3_Linux_X86_64_Full.tar.gz-rw-rw-r--. 1 500 500 122 Sep 21 2016 copyright-rwxrwxr-x. 1 500 500 5629 Sep 21 2016 crtmqpkgdrwxrwxr-x. 4 500 500 51 Sep 21 2016 lapdrwxrwxr-x. 2 500 500 4096 Sep 21 2016 licenses-rwxr-xr-x. 1 500 500 8371 Sep 21 2016 mqlicense.shdrwxrwxr-x. 2 500 500 278 Sep 21 2016 repackage

(3)在容器中安装

[root@6dfcd9f0360c /]# cd /tmp/software/[root@6dfcd9f0360c software]# ./mqlicense.sh -accept WARNING: Unable to determine distribution and release for this system.  Check that it is supported before continuing with installation.Licensed Materials - Property of Vsettan   5724-H72  (C) Copyright Vsettan Corporation 2015,2016 Agreement accepted: Proceed with install.[root@6dfcd9f0360c software]# rpm -ivh *rpmPreparing... ################################# [100%]Creating group mqmCreating user mqmUpdating / installing... 1:ToprowMQRuntime-8.0.0-3 ################################# [ 10%] 2:ToprowMQJRE-8.0.0-3 ################################# [ 20%] 3:ToprowMQExplorer-8.0.0-3 ################################# [ 30%] 4:ToprowMQClient-8.0.0-3 ################################# [ 40%] 5:ToprowMQJava-8.0.0-3 ################################# [ 50%] 6:ToprowMQMsg_Zh_CN-8.0.0-3 ################################# [ 60%] 7:ToprowMQMsg_Zh_TW-8.0.0-3 ################################# [ 70%] 8:ToprowMQSDK-8.0.0-3 ################################# [ 80%] 9:ToprowMQSamples-8.0.0-3 ################################# [ 90%] 10:ToprowMQServer-8.0.0-3 ################################# [100%]Updated PAM configuration in /etc/pam.d/ibmmq

然后exit退出容器。

(4)提交为镜像

查看刚才使用的容器:

[root@centos1 mq]# docker container ls -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESa4ba25fa8af6 centos "/bin/bash" 5 minutes ago Exited (0) 10 seconds ago elated_mccarthy[root@centos1 mq]# docker commit a4ba25fa8af6 shushenlw/toprowmq8003sha256:cb533d56a1f5a9d570c9a983bebe5791e6e03cfc3dfab22bf4b62eacf6e0f407[root@centos1 mq]# docker image ls shushenlw/toprowmq8003REPOSITORY TAG IMAGE ID CREATED SIZEshushenlw/toprowmq8003 latest cb533d56a1f5 About a minute ago 907MB

2. 使用安装MQ的镜像制作可以提供服务的MQ镜像

创建各种MQ对象,然后对外提供服务。

(1)准备各种文件

[root@centos1 mq]# cat Dockerfile FROM shushenlw/toprowmq8003 RUN yum install -y python-setuptools && easy_install supervisor && mkdir -p /var/log/supervisorCOPY supervisord.conf /usr/etc/supervisord.confCOPY start_queue_manager.sh /tool/RUN chmod +x /tool/start_queue_manager.shEXPOSE 1414CMD ["/usr/bin/supervisord"][root@centos1 mq]# cat supervisord.conf [supervisord]nodaemon=true[program:sshd]command=su mqm -c /tool/start_queue_manager.sh[root@centos1 mq]# cat start_queue_manager.sh export QMNAME=QMTESTexport QMPORT=1414source /opt/mqm/bin/setmqenv -scrtmqm -u SYSTEM.DEAD.LETTER.QUEUE $QMNAMEstrmqm $QMNAMErunmqsc $QMNAME << EOF define listener(TCP.LISTENER) trptype(tcp) control(qmgr) port($QMPORT) start listener(TCP.LISTENER) define channel(CHL_SVRCONN) chltype(SVRCONN) REPLACE ALTER QMGR CHLAUTH(DISABLED) ALTER QMGR CONNAUTH('') REFRESH SECURITYEOF(2)build镜像[root@centos1 mq]# docker build --tag shushenlw/toprowmq8003:v1.0 .Sending build context to Docker daemon 5.632kBStep 1/7 : FROM shushenlw/toprowmq8003 ---> cb533d56a1f5Step 2/7 : RUN yum install -y python-setuptools && easy_install supervisor && mkdir -p /var/log/supervisor ---> Running in d0f48ce973c7Loaded plugins: fastestmirror, ovlDetermining fastest mirrors * base: mirrors.163.com * extras: mirrors.huaweicloud.com * updates: mirrors.cqu.edu.cnbase | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 (1/4): base/7/x86_64/group_gz | 166 kB 04:29 (2/4): extras/7/x86_64/primary_db | 201 kB 04:45 (3/4): base/7/x86_64/primary_db | 6.0 MB 06:13 (4/4): updates/7/x86_64/primary_db | 4.2 MB 06:27 Resolving Dependencies--> Running transaction check---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch--> Running transaction check---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch--> Running transaction check---> Package python-backports.x86_64 0:1.0-8.el7 will be installed---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved================================================================================ Package Arch Version Repository Size================================================================================Installing: python-setuptools noarch 0.9.8-7.el7 base 397 kInstalling for dependencies: python-backports x86_64 1.0-8.el7 base 5.8 k python-backports-ssl_match_hostname noarch 3.5.0.1-1.el7 base 13 k python-ipaddress noarch 1.0.16-2.el7 base 34 kTransaction Summary================================================================================Install 1 Package (+3 Dependent packages)Total download size: 450 kInstalled size: 2.2 MDownloading packages:warning: /var/cache/yum/x86_64/7/base/packages/python-backports-1.0-8.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEYPublic key for python-backports-1.0-8.el7.x86_64.rpm is not installed(1/4): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 01:18 (2/4): python-backports-ssl_match_hostname-3.5.0.1-1.el7.n | 13 kB 01:50 (3/4): python-ipaddress-1.0.16-2.el7.noarch.rpm | 34 kB 01:50 (4/4): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 01:50 --------------------------------------------------------------------------------Total 3.5 kB/s | 450 kB 02:09 Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) " Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 Package : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7Running transaction checkRunning transaction testTransaction test succeededRunning transactionWarning: RPMDB altered outside of yum. Installing : python-backports-1.0-8.el7.x86_64 1/4  Installing : python-ipaddress-1.0.16-2.el7.noarch 2/4  Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/4  Installing : python-setuptools-0.9.8-7.el7.noarch 4/4  Verifying : python-ipaddress-1.0.16-2.el7.noarch 1/4  Verifying : python-setuptools-0.9.8-7.el7.noarch 2/4  Verifying : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/4  Verifying : python-backports-1.0-8.el7.x86_64 4/4 Installed: python-setuptools.noarch 0:0.9.8-7.el7 Dependency Installed: python-backports.x86_64 0:1.0-8.el7  python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7  python-ipaddress.noarch 0:1.0.16-2.el7 Complete!Searching for supervisorReading https://pypi.python.org/simple/supervisor/Best match: supervisor 4.0.2Downloading https://files.pythonhosted.org/packages/cb/02/95953c98a770803e42009f18c2eb361bc035ab6fb3cbb442ffcc94387eac/supervisor-4.0.2.tar.gz#sha256=5604457da4fb89d850e78c128205fe4938c9277f87301885b33c94c60361e575Processing supervisor-4.0.2.tar.gzWriting /tmp/easy_install-PRDNNO/supervisor-4.0.2/setup.cfgRunning supervisor-4.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-PRDNNO/supervisor-4.0.2/egg-dist-tmp-JsKCZSwarning: no previously-included files matching '*' found under directory 'docs/.build'Adding supervisor 4.0.2 to easy-install.pth fileInstalling echo_supervisord_conf script to /usr/binInstalling pidproxy script to /usr/binInstalling supervisorctl script to /usr/binInstalling supervisord script to /usr/binInstalled /usr/lib/python2.7/site-packages/supervisor-4.0.2-py2.7.eggProcessing dependencies for supervisorSearching for meld3>=1.0.0Reading https://pypi.python.org/simple/meld3/Best match: meld3 1.0.2Downloading https://files.pythonhosted.org/packages/45/a0/317c6422b26c12fe0161e936fc35f36552069ba8e6f7ecbd99bbffe32a5f/meld3-1.0.2.tar.gz#sha256=f7b754a0fde7a4429b2ebe49409db240b5699385a572501bb0d5627d299f9558Processing meld3-1.0.2.tar.gzWriting /tmp/easy_install-UKscyn/meld3-1.0.2/setup.cfgRunning meld3-1.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UKscyn/meld3-1.0.2/egg-dist-tmp-ikmU68zip_safe flag not set; analyzing archive contents...Adding meld3 1.0.2 to easy-install.pth fileInstalled /usr/lib/python2.7/site-packages/meld3-1.0.2-py2.7.eggFinished processing dependencies for supervisorRemoving intermediate container d0f48ce973c7 ---> 365c08df5698Step 3/7 : COPY supervisord.conf /usr/etc/supervisord.conf ---> f77fc55cd5c9Step 4/7 : COPY start_queue_manager.sh /tool ---> 901ff48aa46dStep 5/7 : RUN chmod +x /start_queue_manager.sh ---> Running in 579b66efbca2Removing intermediate container 579b66efbca2 ---> 7f975388ae10Step 6/7 : EXPOSE 1414 ---> Running in 433c1956e97eRemoving intermediate container 433c1956e97e ---> 20382e828da6Step 7/7 : CMD ["/usr/bin/supervisord"] ---> Running in 4d392c69731aRemoving intermediate container 4d392c69731a ---> fdfed6b58458Successfully built fdfed6b58458Successfully tagged shushenlw/toprowmq8003:v1.0[root@centos1 mq]# docker image lsREPOSITORY TAG IMAGE ID CREATED SIZEshushenlw/toprowmq8003 v1.0 fdfed6b58458 30 seconds ago 1GB
d7b93d5f481a4459e6f0c03e0dab884f.png

查看镜像

(3)启动容器

[root@centos1 mq]# docker run -d -p 1414:1414 --name toprowmq8003 shushenlw/toprowmq8003:v1.0cf12ddcf485e16060a6f8e67a74964da69893b90618d169c8e02ec13c86dc3d1[root@centos1 mq]# docker inspect cf12ddcf485e | grep -i ipaddress "SecondaryIPAddresses": null, "IPAddress": "172.17.0.2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值