您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
[root@localhost ~]# yum install yum-utils device-mapper-persistent-data lvm2 -y
[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@localhost ~]# yum install -y docker-ce
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start docker.service
[root@localhost ~]# systemctl enable docker.service
[root@localhost ~]# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://w1ogxqvl.mirror.aliyuncs.com"]
}
EOF
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# docker pull centos:7
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 7 5e35e350aded 6 weeks ago 203MB
[root@localhost ~]# ls
anaconda-ks.cfg 模板 图片 下载 桌面 initial-setup-ks.cfg 公共 视频 文档 音乐
[root@localhost ~]# mkdir tomcat
[root@localhost ~]# ls
anaconda-ks.cfg tomcat 模板 图片 下载 桌面
initial-setup-ks.cfg 公共 视频 文档 音乐
`接下来的操作需要先把 jdk-8u91-linux-x64.tar.gz 和 apache-tomcat-9.0.16.tar.gz 两个压缩包 下载下来之后放在 /root/tomcat/ 目录下,再直接解压`
[root@localhost ~]# cd tomcat/
[root@localhost tomcat]# ls
jdk-8u91-linux-x64.tar.gz apache-tomcat-9.0.16.tar.gz
[root@localhost tomcat]# tar zxvf jdk-8u91-linux-x64.tar.gz
[root@localhost tomcat]# tar zxvf apache-tomcat-9.0.16.tar.gz
[root@localhost tomcat]# vim Dockerfile
#基于基础镜像
FROM centos:7
MAINTAINER This is tomcat server
ADD jdk-8u91-linux-x64.tar.gz /root
RUN mv /root/jdk1.8.0_91/ /usr/local/jdk1.8
ENV JAVA_HOME=/usr/local/jdk1.8
ENV CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
ENV PATH=$JAVA_HOME/bin:$PATH
ADD apache-tomcat-9.0.16.tar.gz /root
RUN mv /root/apache-tomcat-9.0.16/ /usr/local/tomcat
RUN ln -s /usr/local/tomcat/bin/shutdown.sh /usr/local/bin/;ln -s /usr/local/tomcat/bin/startup.sh /usr/local/bin/
EXPOSE 8080
ENTRYPOINT /usr/local/tomcat/bin/startup.sh && /bin/bash && tail -f /usr/local/tomcat/logs/catalina.out
[root@localhost tomcat]# docker build -t tomcat:centos
[root@localhost tomcat]# docker run -d -P tomcat:centos
61946199e564f72903d17f70d0d1d14627d7b01e5dc80a808936866c494fc1c5
[root@localhost tomcat]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
61946199e564 tomcat:centos "/bin/sh -c '/usr/lo…" 12 seconds ago Up 11 seconds 0.0.0.0:32768->8080/tcp quirky_wilbur
#端口为32768
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。