docker-compose.yaml的编写

当我们打包好了镜像的时候,一个一个区整理的时候,也是很浪费功夫,尤其是我们修改了一些代码的时候

version: "2"
services:
    mysql:
        image: mysql:mysql
        hostname: mysql
        ports:
            - "3306:3306"
        volumes:
            - "/data/mysql:/var/lib/mysql"
        restart: always
    backend:
        image: backend:0.5
        command: "python3 main.py"
        hostname: backend
        volumes:
            - "/data/files:/app/files"
        network_mode: "host"
        depends_on:
            - mysql
        restart: always
    frontend:
        image: frontend:0.5
        hostname: frontend
        volumes:
            - "/Users/gaven/Desktop/anji/frontend/web/nginx.conf:/etc/nginx/nginx.conf"
            - "/Users/gaven/Desktop/anji/frontend/web/default.conf:/etc/nginx/conf.d/default.conf"
        ports:
            - "80:80"
        network_mode: "host"
        restart: always

你可能感兴趣的:(docker)