操作系统:windows 10
1.从官方下载tomcat镜像
docker pull tomcat:7.0-jre8
2.生成ssl证书
keytool -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore
3.根据官方镜像启动容器,并本地目录挂载到容器中
docker -it -d -v E:\projects\study\docker\busybox\ssl:/tmp
4.进入容器
docker exec -it 容器ID /bin/bash
5.拷贝证书到容器中
root@887a6ec5aeec:/usr/local/tomcat# ls
LICENSE NOTICE RELEASE-NOTES RUNNING.txt bin conf lib logs temp webapps work
root@887a6ec5aeec:/usr/local/tomcat# ls /tmp/
tomcat.keystore
root@887a6ec5aeec:/usr/local/tomcat# mkdir keys
root@887a6ec5aeec:/usr/local/tomcat# cp /tmp/tomcat.keystore keys/
root@887a6ec5aeec:/usr/local/tomcat#
6.修改tomcat的server.xml配置文件
添加如下信息
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" keystoreFile="/usr/local/tomcat/keys/tomcat.keystore" keystorePass="123456" sslProtocol="TLS" />
7.提交容器生成一个镜像
docker commit 容器id tomcat:https
8.验证镜像是否成功
docker run –p 80:8080 -p 443:8443 tomcat:https
网友评论