本文最后更新于 2024年1月12日 下午
Docker-compose
标准配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| services: example: image: example/example:latest container_name: example configs: - uid: "" - gid: "" depends_on: - exa1 - exa2 dns: - 1.1.1.1 env_file: .env environment: - test=test - TZ=utc extends: file:test.yml service: exa1 healthcheck: test: ["CMD", "curl", "-f", "http://localhost"] interval: 1m30s timeout: 10s retries: 3 start_period: 40s start_interval: 5s hostname: exa1 ports: - "127.0.0.1:22221:22221/tcp" stdin_open: true tty: true shm_size: 300m storage_opt: size: "1G" user: exa volumes: - type: volume source: db-data target: /data volume: volumes: "VOLUME:CONTAINER_PATH:ACCESS_MODE" volumes: db-data: driver_opts: type: "ext4" device: ":/docker/example"
|
Services
image
容器镜像位置
container_name
容器在docker里的命名
depends_on
容器将会比列表的容器先关闭、后启动
restart
“no”
always
on-failure
unless-stopped