云计算
1.创建目录
[root@ticent docker]#mkdir /home/docker
2.下载tomcat
[root@ticent docker]#wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.0.45/bin/apache-tomcat-8.0.44.tar.gz
3.下载jdk
[root@ticent docker]# wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz
4.解压到当前目录
5.编辑Dockerfile
[root@ticent docker]#vi Dockerfile
点击(
此处
)折叠或打开
FROM centos:latest
#install jdk
ADD jdk1.8.0_131 /opt/jdk8
ENV JAVA_HOME /opt/jdk8
ENV PATH $PATH:$JAVA_HOME/bin
RUN mkdir -p "$JAVA_HOME"
#install tomcat
ADD tomcat8 /opt/tomcat8
ENV CATALINA_HOME /opt/tomcat8
ENV PATH $CATALINA_HOME/bin:$PATH
RUN mkdir -p "$CATALINA_HOME"
WORKDIR $CATALINA_HOME
EXPOSE 8080
CMD ["catalina.sh", "run"]
6.本地centos镜像,此处使用
centos:latest
7.构建镜像
[root@ticent docker]# docker build -t tomcat8 .
8.启动,tomcat端口映射到18080
[root@ticent docker]# docker run -d -p 18080:8080 tomcat8
9.查看docker进程
[root@ticent docker]# docker ps
10.访问tomcat
11.进入容器
docker exec -it 65f238010b2c /bin/bash
12.该文中使用centos的镜像,手动将jdk、tomcat构建到镜像中,可以更方便地定制运行环境