Docker容器

Docker: docker-compose

本文主要是介绍Docker: docker-compose,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
version: "3.9"

volumes:
  data:
    external: false
  config:
    external: false
  plugins:
    external: false
  kibana:
    external: false

networks:
  demo:
    name: demo
    external: false
    ipam:
      driver: default
      config:
        - subnet: 10.0.0.0/24

services:
  elasticsearch:
    container_name: elasticsearch
    image: elasticsearch:8.1.0
    ports:
      - 9200:9200
      - 9300:9300
    networks:
      - elasticsearch
    environment:
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
    volumes:
      - data:/usr/share/elasticsearch/data
      - config:/usr/share/elasticsearch/config
      - plugins:/usr/share/elasticsearch/plugins
  kibana:
    container_name: kibana
    image: kibana:8.1.0
    ports:
      - 5601:5601
    networks:
      - elasticsearch
    volumes:
      - kibana:/usr/share/kibana/config
    depends_on:
      - elasticsearch
  demo:
    build:
      context: demo # Dockerfile所在目录
      dockerfile: Dockerfile
    container_name: demo
    deploy:
      replicas: 1
      resources:
        limits:
          cpus: "0.50"
          memory: 500M
        reservations:
          memory: 500M
      restart_policy:
        condition: on-failure
        max_attempts: 3
    dns:
      - 8.8.8.8
      - 9.9.9.9
    dns_search:
      - dc1.example.com
      - dc2.example.com
    entrypoint: /code/entrypoint.sh
    entrypoint: ["php", "-d", "memory_limit=-1", "vendor/bin/phpunit"]
    env_file:
      - ./common.env
      - ./apps/web.env
      - /opt/runtime_opts.env
    command: "redis-server --appendonly yes"
    ports:
      - target: 80
        published: 8080
        protocol: tcp
        mode: host
    healthcheck:
      test: ['CMD','curl','-f','http://localhost']
      interval: 1m30s
      timeout: 10s
      retries: 3
    sysctls:
      - net.core.somaxconn=1024
      - net.ipv4.tcp_syncookies=0
    ulimits:
      nproc: 65535
      nofile:
        soft: 20000
        hard: 40000
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
    volumes:
      - type: volume
        source: mydata
        target: /data
        volume:
          nocopy: true
      - type: bind
        source: ./static
        target: /opt/app/static

 

这篇关于Docker: docker-compose的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!