services:
  test:
    cap_add:
      - NET_ADMIN
    cap_drop:
      - ALL
    command: ["nginx", "updated", "command"]
    cpus: 0.5
    pid: host
    deploy:
      update_config:
        order: stop-first
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0:rw
      - /dev/sda:/dev/xvda
    entrypoint: ["/updated-docker-entrypoint.sh"]
    environment:
      BOOL: "true"
      EMPTY: ""
      VAR: value
    gpus: all
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost"]
      interval: 1m30s
      timeout: 10s
      retries: 5
      start_period: 15s
      start_interval: 2s
    image: nginx:latest
    init: true
    logging:
      driver: json-file
      options:
        max-size: 10m
        max-file: 3
    mem_limit: 100M
    mem_reservation: 50M
    shm_size: 268435456
    privileged: true
    pull_policy: always
    scale: 3
    stop_grace_period: 30s
    sysctls:
      - net.ipv4.ip_forward=1
    ulimits:
      nofile:
        soft: 20000
        hard: 40000
      nproc: 65535
    user: nginx:nginx
    volumes:
      - /etc/passwd:/host/etc/passwd:ro
      - data1:/data1
      - type: bind
        source: /path/on/host
        target: /path/in/container
        read_only: true
        bind:
          create_host_path: true
          propagation: rprivate
      - type: volume
        source: data3-labeled
        target: /data3
        volume:
          nocopy: true
          subpath: app/data
      - type: volume
        source: data2-alias
        target: /data2/long/syntax
      - data-external:/external:ro
      - type: tmpfs
        target: /tmpfs
        tmpfs:
          size: 10485760
          mode: 1770
    x-machines: ["machine-1", "machine-2"]
    x-ports:
      - test.example.com:80/https
      - 8000/http
      - 5000:3000@host
    x-pre_deploy:
      command: ["sh", "-c", "migrate"]
      environment:
        DB_HOST: localhost
      privileged: false
      timeout: 2m30s
      user: root

  test-caddy-config:
    image: myapp:1.2.3
    # x-ports and x-caddy are mutually exclusive.
    x-caddy: |
      test-caddy-config.example.com {
        reverse_proxy {{ upstreams 80 }}
      }

volumes:
  data1:
  data2-alias:
    name: data2
    driver: local
  data3-labeled:
    labels:
      env: test
  data-external:
    external: true
