docker-compose 容器编排

nginx

version: "3"
services: # 服务
nginx:
image: ngin124:latest
ports: # 将本机的 8080 端口映射到容器的80端口
- "8080:80"
container_name: nginx-yaml
restart: always
volumes: # 映射本机 F:/nginx.conf 文件到 容器的 /etc/nginx/nginx.conf:ro 文件
- /usr/local/nginx1.24/html:/usr/local/nginx-1.24/html
- /usr/local/nginx1.24/conf/nginx.conf:/usr/local/nginx-1.24/conf/nginx.conf
networks:
- "my-network"
networks: # 网络
my-network: # 网络名称
driver: bridge

redis

version: "3"
services: # 服务
redis:
image: redis7.2.1:latest
ports:
- "6379:6379"
container_name: redis-yaml
restart: always
volumes:
- /etc/redis.conf:/usr/local/redis7.2.1/conf
networks:
- "my-network"
networks:
my-network:
driver: bridge

tomcat

version: "3"
services: # 服务
tomcat:
image: tomcat8.5.93:latest
ports:
- "9090:8080"
container_name: tomcat-yaml
restart: always
volumes:
- /usr/local/tomcat-8.5.93/conf/server.xml:/usr/local/apache-tomcat-8.5.93/conf/server.xml
networks:
- "my-network"
networks:
my-network:
driver: bridge