Docker从入门到娴熟之Docker Compose

如皋娱乐新闻网 2025-11-01

compose-spec/compose-spec · GitHub

version

所选本 yml 依循的 compose发行版

services

假定多个应用咨询服务,还包括环境的设计、终端实现等

build

所选实现终端的逆时针

version: "3.9"services: webapp: build: ./appblkio_config

假定咨询服务的block IO的设计,参考资料compose-spec/spec.md at master · compose-spec/compose-spec · GitHub

container_name

所选自假定桶内名称

depends_on

假定咨询服务间启动时或暂停的缺少人关系

services: web: build: . depends_on: - db - redis redis: image: redis db: image: postgrescommand

构成桶内启动时的选项命令

command: [ "bundle", "exec", "thin", "-p", "3000" ]domainname

domainname declares a custom domain name to use for the service container.

entrypoint

构成桶内选项的entrypoint

env_file

从份文件中添加环境变量到桶内,可以是一个或多个份文件

env_file: .envenv_file: - ./a.env - ./b.env

份文档:

# Set Rails/Rack environmentRACK_ENV=developmentVAR="quoted"environment

添加环境变量

environment: RACK_ENV: development SHOW: "true" USER_INPUT:expose

受伤害路由器,但不连续函数到宿伺服器,只被相连的咨询服务访问,仅可以所选内外路由器

expose: - "3000" - "8000"healthcheck

可用扫描 docker 咨询服务确实健康列车运行。

healthcheck: test: ["CMD", "curl", "-f", ""] # 增设扫描程序 interval: 1m30s # 增设扫描间距 timeout: 10s # 增设扫描超时时间 retries: 3 # 增设重试次数 start_period: 40s # 启动时后,多少秒开始启动时扫描程序image

所选桶内列车运行的终端

image: redis:5labels

增设桶内标签

labels: com.example.description: "Accounting webapp" com.example.department: "Finance"labels: - "com.example.description=Accounting webapp" - "com.example.department=Finance"links

相连到另一个桶内的互联网,简单将就是让桶内相互连通

web: links: - db - db:database - redislogging

咨询服务的日志记录的设计,driver:所选咨询服务桶内的日志记录驱动程式,选项值为json-file。有一般而言三个的系统

driver: "json-file"driver: "syslog"driver: "none"

仅在 json-file 驱动程式下,可以适用一般而言值,受限制日志得适用量和较小。

logging: driver: json-file options: max-size: "200k" # 单个份比特率为200k max-file: "10" # 最多10个份文件

syslog 驱动程式下,可以适用 syslog-address 所选日志交还重定向。

logging: driver: syslog options: syslog-address: "tcp://192.168.0.42:123"network_mode

增设互联网方式而,文档如下:

network_mode: "bridge" #桥接方式而network_mode: "host"network_mode: "none"network_mode: "service:[service name]"networks

的设计桶内相连的互联网

services: some-service: networks: - some-network - other-networknetworks: some-network: # Use a custom driver driver: custom-driver-1 other-network: # Use a custom driver which takes special options driver: custom-driver-2services: frontend: image: awesome/webapp networks: - front-tier - back-tier monitoring: image: awesome/monitoring networks: - admin backend: image: awesome/backend networks: back-tier: aliases: - database admin: aliases: - mysqlnetworks: front-tier: back-tier: admin:ipv4_address, ipv6_address

所选ip重定向

services: frontend: image: awesome/webapp networks: front-tier: ipv4_address: 172.16.238.10 ipv6_address: 2001:3984:3989::10networks: front-tier: ipam: driver: default config: - subnet: "172.16.238.0/24" - subnet: "2001:3984:3989::/64"ports

路由器连续函数,连续函数伺服器与桶内路由器,文档:Host:ontainer

ports: - "5000:5000"Restart

桶内重启策略

restart: "no"restart: alwaysrestart: on-failurerestart: unless-stoppedsecrets

存储敏感数据,比如密码

services: frontend: image: awesome/webapp secrets: - server-certificatesecrets: server-certificate: file: ./server.certvolumes

将伺服器数据卷可携带到桶内

services: db: image: postgres:latest volumes: - "/localhost/postgres.sock:/var/run/postgres/postgres.sock" - "/localhost/data:/var/lib/postgresql/data"working_dir

构成桶内工作附录

Volumes 顶级附录services: backend: image: awesome/database volumes: - db-data:/etc/data backup: image: backup-service volumes: - db-data:/var/lib/backup/datavolumes: db-data:Networks 顶级附录services: frontend: image: awesome/webapp networks: - front-tier - back-tiernetworks: front-tier: back-tier: driver: bridgedocker-compose 命令$ docker-compose ;还有helpDefine and run multi-container applications with Docker.Usage: docker-compose [-f ...] [;还有profile ...] [options] [COMMAND] [ARGS...] docker-compose -h|;还有helpOptions: -f, ;还有file FILE Specify an alternate compose file (default: docker-compose.yml) -p, ;还有project-name NAME Specify an alternate project name (default: directory name) ;还有profile NAME Specify a profile to enable ;还有verbose Show more output ;还有log-level LEVEL Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) ;还有no-ansi Do not print ANSI control characters -v, ;还有version Print version and exit -H, ;还有host HOST Daemon socket to connect to ;还有tls Use TLS; implied by ;还有tlsverify ;还有tlscacert CA_PATH Trust certs signed only by this CA ;还有tlscert CLIENT_CERT_PATH Path to TLS certificate file ;还有tlskey TLS_KEY_PATH Path to TLS key file ;还有tlsverify Use TLS and verify the remote ;还有skip-hostname-check Don't check the daemon's hostname against the name specified in the client certificate ;还有project-directory PATH Specify an alternate working directory (default: the path of the Compose file) ;还有compatibility If set, Compose will attempt to convert deploy keys in v3 files to their non-Swarm equivalentCommands: build Build or rebuild services bundle Generate a Docker bundle from the Compose file config Validate and view the Compose file create Create services down Stop and remove containers, networks, images, and volumes events Receive real time events from containers exec Execute a command in a running container help Get help on a command images List images kill Kill containers logs View output from containers pause Pause services port Print the public port for a port binding ps List containers pull Pull service images push Push service images restart Restart services rm Remove stopped containers run Run a one-off command scale Set number of containers for a service start Start services stop Stop services top Display the running processes unpause Unpause services up Create and start containers version Show the Docker-Compose version informationSwarm集群。

芜湖看白癜风到哪个医院好
临夏治疗白癜风医院
口腔科
春季祛痘
祛眼袋
口臭偏方
严重咳嗽吃什么药能快速止咳
急支糖浆适合哪种咳嗽
相关阅读

峡谷晚报:管泽元怒评国足|最初英雄逆天机制复活队友策反对手

星闻 2025-11-06

大家好!注目现场直播山谷报第365期,衷心大家在另行的一年都能虎虎生威! 另行坏蛋Renata熟练曝光:W熟练可复活后撤 LOL官方公开发表炼金女爵思娜石塔•纳医学

从GDP看各地位数经济

资讯 2025-11-06

速位数政治经济等综合和上新兴新能源领域议案。天津赛艇原始数据处理高大上,在西部盆地里头的云南,位数政治经济的分析方法情景有着更是接地气的存在。前年9年末1日,转成都地锰“刷脸乘车”功能月底上线

男童吐槽婚房被父母装修得太土,网友:全屋都是原木,还不知足?

综艺 2025-11-06

你希望把自己的婚房交还给继父来翻新吗?随之而来这样的恶魔拷问,确实很多青年人不会反之亦然拒绝。似乎以致于一想也是这样的谜题。无论如何继父辈的品味,和时时青年人的品味,不一定在一条水平线上。p

《百战天虫》开发商Team17被喷后宣布更改NFT项目

星闻 2025-11-06

《百战天虫》技术开发商Team17被喷后年初取消NFT工程建设 在技术开发人员、间公司该工作室以及FANS的尖锐反对者后,Team17现在(2同年2号)年初取消 《百战天虫》的

买空调,定频好还是电控好?商家:内行人买定频,外行人买电控

八卦 2025-11-06

去商场要买冷气,电控冷气占据半壁江山,择扰冷气越来越少。我特意问过商店,为何大家都不要买择扰冷气了?看我是半个懂先为人,他告诉我: 其实只不过懂先为的人还是会要买择扰

友情链接