docker search tomcat
docker pull tomcat:8.5
- 创建一个后台运行的容器,并实现端口的重定向,挂载目录到宿主机的指定位置,且随docker服务启动而启动(
参数:--restart=always
)
docker run -d -p 8088:8080 --name docker-tomcat8.5 -v /root/tomcat_webapps:/var/local/tomcat/webapps --restart=always tomcat:8.5
docker container update --restart=always docker-tomcat8.5
docker inspect docker-tomcat8.5 | grep Id -A 0
docker ps
docker ps -a
docker ps -l
docker images
docker rm docker-tomcat8.5
docker rmi 551efb60a0a2
docker start docker-tomcat8.5
docker stop docker-tomcat8.5
docker restart docker-tomcat8.5
docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)
docker exec -it docker-tomcat8.5 bash
docker cp /root/tomcat_mount/conf/tomcat-user.xml docker-tomcat8.5:/usr/local/tomcat/conf
docker cp docker-tomcat8.5:/usr/local/tomcat/conf/tomcat-user.xml /root/tomcat_mount/conf
docker commit -a "作者" -m "描述" -p docker-tomcat8.5 docker-images-tomcat8.5
- 将镜像打包成tar包(
两个不同的命令都可以打包,但第一种在容器比较大的情况下可能打包失败
)
docker save -o /root/resources/docker-images-tomcat8.5.tar docker-images-tomcat8.5
docker save docker-images-tomcat8.5 > /root/resources/docker-images-tomcat8.5.tar
docker load < mydocker-tomcat8.5.tar