环境说明:docker pulltomcat镜像,映射本地文件运行容器
docker pull iabhi/tomcat-alpine:8.5.23
注意这里的tomcat版本最好8版本的,太高有问题
docker run -id -d -p 8082:8080 --name envirmnet -v /root/java/envirment/:/usr/local/apache-tomcat-8.5.23/webapps/ROOT/WEB-INF/ -v /root/java/logs:/usr/local/apache-tomcat-8.5.23/logs/ --restart=always iabhi/tomcat-alpine:8.5.23
-p8083:8080 左边8083为服务器对外端口,右边8080为容器内tomcat端口
-v /root/java/envirment/:/usr/local/apache-tomcat-8.5.23/webapps/
左边 /root/java/envirment/为服务器envirment位置,随意自定义(classes/ lib/ web.xml)
右边/usr/local/apache-tomcat-8.5.23/webapps/为容器内tomcat路径,这个路径一定要搞清,一开始老认为是/usr/local/tomcat
–restart=always 开机启动容器,防止docker或者服务器重启,容器没有跟随启动
docker exec -it envirment /bin/bash
Error response from daemon: OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: “/bin/bash”: stat /bin/bash: no such file or directory: unknown
解决办法:
docker exec -it jenkins /bin/sh
or
docker exec -it jenkins bash
or
docker exec -it jenkins sh
docker exec -it jenkins /bin/sh