写点什么

极客时间运维进阶训练营第三周作业

作者:chenmin
  • 2022-11-13
    新疆
  • 本文字数:1447 字

    阅读完需:约 5 分钟

1.基于 docker-compose 实现对 Nginx+Tomcat Web 服务的单机编排

#1.编辑yml配置文件root@chen:/app/test# vi nginx-tomcat.ymlversion: '3.8'services:  nginx-server:    image: nginx:1.22.0    container_name: nginx_web    expose:      - 80      - 443    ports:      - "8090:80"      - "8443:443"    networks:      - front      - backend    links:  # Depends on tomcat server service      - tomcat-server
tomcat-server: image: registry.cn-hangzhou.aliyuncs.com/zhangshijie/tomcat-myapp:v1 container_name: tomcat-app1 networks: - backend links: # Depends on mysql server service - mysql-server
mysql-server: image: mysql:5.7 container_name: mysql-server # volumes: # - /data/mysql/conf/my.cnf:/etc/my.cnf:ro environment: - "MYSQL_ROOT_PASSWORD=12345678" - "TZ=America/NewYork" expose: - 3306 ports: - "3306:3306" networks: - backend
networks: front: driver: bridge backend: driver: bridge default: external: name: bridge #2.应用配置文件root@chen:/app/test# docker-compose -f nginx-tomcat.yml up -dWARN[0000] network default: network.external.name is deprecated in favor of network.name[+] Running 4/4 ⠿ Container mysql-app Recreated 0.4s ⠿ Container tomcat-app1 Started 1.8s ⠿ Container nginx_web Started 3.9s ⠿ Container mysql-server Started
#3.验证部署root@chen:/app/test# docker-compose -f nginx-tomcat.yml psWARN[0000] network default: network.external.name is deprecated in favor of network.nameNAME COMMAND SERVICE STATUS PORTSmysql-server "docker-entrypoint.s…" mysql-server running 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcpnginx_web "/docker-entrypoint.…" nginx-server running 0.0.0.0:8090->80/tcp, :::8090->80/tcp, 0.0.0.0:8443->443/tcp, :::8443->443/tcptomcat-app1 "/apps/tomcat/bin/do…" tomcat-server running 8080/tcp, 8443/tcp
复制代码

test test test test test test test test test

test test test test test test test test test

test test test test test test test test test

用户头像

chenmin

关注

还未添加个人签名 2018-02-26 加入

还未添加个人简介

评论

发布
暂无评论
极客时间运维进阶训练营第三周作业_chenmin_InfoQ写作社区