docker-compos聯合兩個容器

使用網絡

version: '2' services: web: image: http networks: - myappnet1 worker: image: http networks: - myappnet2 db: image: http networks: myappnet1: aliases: - database myappnet2: aliases: - mysql networks: myappnet1: myappnet2:



 

使用links

 version: '2' services: web: image: http container_name: web depends_on: - db ports: - "9090:80" links: - db:mysql - db:databases db: image: mariadb container_name: db environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress

 

 

version: '2' services: web: image: lap container_name: web restart: always depends_on: - db ports: - "80:80" networks: - mynet volumes: - /etc/localtime:/etc/localtime:ro - /home/www:/var/www db: image: mariadb container_name: db restart: always networks: mynet: aliases: - mysql - db - database environment: MYSQL_ROOT_PASSWORD: example volumes: - /etc/localtime:/etc/localtime:ro - /home/mysql/data:/var/lib/mysql networks: mynet:
相關文章
相關標籤/搜索