标签:修改 idt 运行 tomcat8 变量 contain 启动 交互式 非交互式
docker部署TOMCAT项目
一、内核升级
[root@test01 ~]# uname -r #内核查看确认 2.6.32-696.16.1.el6.x86_64 [root@test01 ~]# [root@test01 ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org [root@test01 ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm #安装yum源 Retrieving http://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm Preparing... ########################################### [100%] 1:elrepo-release ########################################### [100%] [root@test01 ~]# yum --enablerepo=elrepo-kernel install kernel-lt -y
修改grub.conf文件 内核升级完毕后修改内核的启动顺序
vim /etc/grub.conf default=0 |
二、docker 安装
安装Yum 源 yum -y install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 更新Yum yum update 安装DOCKER yum install docker-io 查看docker版本 docker version 启动 重启 停止 service docker start service docker restart service docker stop |
二、制作Tomcat DOCKER镜像
在tomcat-docker目录下执行命令touch Dockerfile创建一个Dockerfile文件
Vim Dockerfile内容如下,之后保存
# 设置继承的镜像 FROM centos:6.8 # 创建者信息 MAINTAINER qin # 设置环境变量,所有操作都是非交互式的 ENV DEBIAN_FRONTEND noninteractive # 设置tomcat的环境变量 ENV CATALINA_HOME /tomcat ENV JAVA_HOME /java # 复制tomcat和jdk文件到镜像中 ADD tomcat /tomcat ADD java /java # 复制启动脚本至镜像,并赋予脚本可执行权限 ADD run.sh /run.sh RUN chmod +x /*.sh RUN chmod +x /tomcat/bin/*.sh # 暴露接口8091,这是我的tomcat接口,默认为8080 EXPOSE 8091 # 设置自启动命令 CMD ["/run.sh"]
|
生成镜像
docker build -t repos_local/centos6.8-jdk151-tomcat8:0.0.1 . Sending build context to Docker daemon 416.5 MB Sending build context to Docker daemon Step 0 : FROM centos:6.8 6.8: Pulling from centos 3690474eb5b4: Pull complete 131c774986bb: Pull complete 418a4141e182: Pull complete e8cf8129749b: Pull complete Digest: sha256:d5c1a93ff48ffe6894f92cf3a967d9552929c51aae279d9f0589508644556bd3 Status: Downloaded newer image for centos:6.8 ---> e8cf8129749b Step 1 : MAINTAINER qincx ---> Running in 816dc6cdfc1a ---> abb8174c6c8c Removing intermediate container 816dc6cdfc1a Step 2 : ENV CATALINA_HOME /tomcat ---> Running in e11aa7f3aa09 ---> a03f42945da8 Removing intermediate container e11aa7f3aa09 Step 3 : ENV JAVA_HOME /java ---> Running in 1c3e278eccb8 ---> 763f32c6f0fd Removing intermediate container 1c3e278eccb8 Step 4 : ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin ---> Running in 3b69460ab841 ---> 9779839b1e58 Removing intermediate container 3b69460ab841 Step 5 : ADD tomcat /tomcat ---> d20bfb40a369 Removing intermediate container f04fe0368412 Step 6 : ADD java /java ---> e941e05d64a2 Removing intermediate container 1c05ea7d45f4 Step 7 : EXPOSE 8080 ---> Running in 2d4f9f6e7d2f ---> b68a2ecaca4b Removing intermediate container 2d4f9f6e7d2f Step 8 : EXPOSE 8762 ---> Running in 729817b4fc18 ---> e7a7fd6d5397 Removing intermediate container 729817b4fc18 Step 9 : EXPOSE 8761 ---> Running in 45c59fa5dd0c ---> e439483994ce Removing intermediate container 45c59fa5dd0c Step 10 : CMD /tomcat/bin/catalina.sh run ---> Running in 7d65e12d018d ---> d3ad75494703 Removing intermediate container 7d65e12d018d Successfully built d3ad75494703 |
查看镜像
docker images |
删除DOCKER镜像
docker rmi 3690474eb5b4 |
停止运行的DOCKER进程
docker rm $(docker ps -a -q) |
标签:修改 idt 运行 tomcat8 变量 contain 启动 交互式 非交互式
原文地址:https://www.cnblogs.com/fishbook/p/9229778.html