docker compose安装
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
docker 实例-docker-compose-tomcat.yml
version: "3.8"
services:
tomcat:
image: tomcat
container_name: tomcat
restart: always
# network_mode: "host"
environment:
- JAVA_OPTS=-server -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC
ports:
- "7005:8005"
- "7080:8080"
volumes:
- ./logs:/usr/local/tomcat/logs
- ./webapps:/usr/local/tomcat/webapps
实例说明
(1)这里7005是对端口8005的映射
docker componse 的常用命令
docker-componse -f docker-componse-tomcat.yml up -d 启动所有
docker-componse -f docker-componse-tomcat.yml up -d tomcat 启动tomcat服务
docker-comonse -f docker-compose-tomcat.yml down 停止
docker rm -f tomcat 停止并删除tomcat服务
docker images|grep tomcat 查看tomat images