亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
Compose About versions and upgrading (Compose) ASP.NET Core + SQL Server on Linux (Compose) CLI environment variables (Compose) Command-line completion (Compose) Compose(組成) Compose command-line reference(組合命令行參考) Control startup order (Compose) Django and PostgreSQL (Compose) Docker stacks and distributed application bundles (Compose) docker-compose build(docker-compose構(gòu)建) docker-compose bundle docker-compose config docker-compose create docker-compose down docker-compose events docker-compose exec docker-compose help docker-compose images docker-compose kill docker-compose logs docker-compose pause docker-compose port docker-compose ps docker-compose pull docker-compose push docker-compose restart docker-compose rm docker-compose run docker-compose scale docker-compose start docker-compose stop docker-compose top docker-compose unpause docker-compose up Environment file (Compose) Environment variables in Compose Extend services in Compose Frequently asked questions (Compose) Getting started (Compose) Install Compose Link environment variables (deprecated) (Compose) Networking in Compose Overview of Docker Compose Overview of docker-compose CLI Quickstart: Compose and WordPress Rails and PostgreSQL (Compose) Sample apps with Compose Using Compose in production Using Compose with Swarm Engine .NET Core application (Engine) About images, containers, and storage drivers (Engine) Add nodes to the swarm (Engine) Apply custom metadata (Engine) Apply rolling updates (Engine) apt-cacher-ng Best practices for writing Dockerfiles (Engine) Binaries (Engine) Bind container ports to the host (Engine) Breaking changes (Engine) Build your own bridge (Engine) Configure container DNS (Engine) Configure container DNS in user-defined networks (Engine) CouchDB (Engine) Create a base image (Engine) Create a swarm (Engine) Customize the docker0 bridge (Engine) Debian (Engine) Default bridge network Delete the service (Engine) Deploy a service (Engine) Deploy services to a swarm (Engine) Deprecated Engine features Docker container networking (Engine) Docker overview (Engine) Docker run reference (Engine) Dockerfile reference (Engine) Dockerize an application Drain a node (Engine) Engine FAQ (Engine) Fedora (Engine) Get started (Engine) Get started with macvlan network driver (Engine) Get started with multi-host networking (Engine) How nodes work (Engine) How services work (Engine) Image management (Engine) Inspect the service (Engine) Install Docker (Engine) IPv6 with Docker (Engine) Join nodes to a swarm (Engine) Legacy container links (Engine) Lock your swarm (Engine) Manage nodes in a swarm (Engine) Manage sensitive data with Docker secrets (Engine) Manage swarm security with PKI (Engine) Manage swarm service networks (Engine) Migrate to Engine 1.10 Optional Linux post-installation steps (Engine) Overview (Engine) PostgreSQL (Engine) Raft consensus in swarm mode (Engine) Riak (Engine) Run Docker Engine in swarm mode Scale the service (Engine) SDKs (Engine) Select a storage driver (Engine) Set up for the tutorial (Engine) SSHd (Engine) Storage driver overview (Engine) Store service configuration data (Engine) Swarm administration guide (Engine) Swarm mode key concepts (Engine) Swarm mode overlay network security model (Engine) Swarm mode overview (Engine) Understand container communication (Engine) Use multi-stage builds (Engine) Use swarm mode routing mesh (Engine) Use the AUFS storage driver (Engine) Use the Btrfs storage driver (Engine) Use the Device mapper storage driver (Engine) Use the OverlayFS storage driver (Engine) Use the VFS storage driver (Engine) Use the ZFS storage driver (Engine) Engine: Admin Guide Amazon CloudWatch logs logging driver (Engine) Bind mounts (Engine) Collect Docker metrics with Prometheus (Engine) Configuring and running Docker (Engine) Configuring logging drivers (Engine) Control and configure Docker with systemd (Engine) ETW logging driver (Engine) Fluentd logging driver (Engine) Format command and log output (Engine) Google Cloud logging driver (Engine) Graylog Extended Format (GELF) logging driver (Engine) Journald logging driver (Engine) JSON File logging driver (Engine) Keep containers alive during daemon downtime (Engine) Limit a container's resources (Engine) Link via an ambassador container (Engine) Log tags for logging driver (Engine) Logentries logging driver (Engine) PowerShell DSC usage (Engine) Prune unused Docker objects (Engine) Run multiple services in a container (Engine) Runtime metrics (Engine) Splunk logging driver (Engine) Start containers automatically (Engine) Storage overview (Engine) Syslog logging driver (Engine) tmpfs mounts Troubleshoot volume problems (Engine) Use a logging driver plugin (Engine) Using Ansible (Engine) Using Chef (Engine) Using Puppet (Engine) View a container's logs (Engine) Volumes (Engine) Engine: CLI Daemon CLI reference (dockerd) (Engine) docker docker attach docker build docker checkpoint docker checkpoint create docker checkpoint ls docker checkpoint rm docker commit docker config docker config create docker config inspect docker config ls docker config rm docker container docker container attach docker container commit docker container cp docker container create docker container diff docker container exec docker container export docker container inspect docker container kill docker container logs docker container ls docker container pause docker container port docker container prune docker container rename docker container restart docker container rm docker container run docker container start docker container stats docker container stop docker container top docker container unpause docker container update docker container wait docker cp docker create docker deploy docker diff docker events docker exec docker export docker history docker image docker image build docker image history docker image import docker image inspect docker image load docker image ls docker image prune docker image pull docker image push docker image rm docker image save docker image tag docker images docker import docker info docker inspect docker kill docker load docker login docker logout docker logs docker network docker network connect docker network create docker network disconnect docker network inspect docker network ls docker network prune docker network rm docker node docker node demote docker node inspect docker node ls docker node promote docker node ps docker node rm docker node update docker pause docker plugin docker plugin create docker plugin disable docker plugin enable docker plugin inspect docker plugin install docker plugin ls docker plugin push docker plugin rm docker plugin set docker plugin upgrade docker port docker ps docker pull docker push docker rename docker restart docker rm docker rmi docker run docker save docker search docker secret docker secret create docker secret inspect docker secret ls docker secret rm docker service docker service create docker service inspect docker service logs docker service ls docker service ps docker service rm docker service scale docker service update docker stack docker stack deploy docker stack ls docker stack ps docker stack rm docker stack services docker start docker stats docker stop docker swarm docker swarm ca docker swarm init docker swarm join docker swarm join-token docker swarm leave docker swarm unlock docker swarm unlock-key docker swarm update docker system docker system df docker system events docker system info docker system prune docker tag docker top docker unpause docker update docker version docker volume docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm docker wait Use the Docker command line (Engine) Engine: Extend Access authorization plugin (Engine) Docker log driver plugins Docker network driver plugins (Engine) Extending Engine with plugins Managed plugin system (Engine) Plugin configuration (Engine) Plugins API (Engine) Volume plugins (Engine) Engine: Security AppArmor security profiles for Docker (Engine) Automation with content trust (Engine) Content trust in Docker (Engine) Delegations for content trust (Engine) Deploying Notary (Engine) Docker security (Engine) Docker security non-events (Engine) Isolate containers with a user namespace (Engine) Manage keys for content trust (Engine) Play in a content trust sandbox (Engine) Protect the Docker daemon socket (Engine) Seccomp security profiles for Docker (Engine) Secure Engine Use trusted images Using certificates for repository client verification (Engine) Engine: Tutorials Engine tutorials Network containers (Engine) Get Started Part 1: Orientation Part 2: Containers Part 3: Services Part 4: Swarms Part 5: Stacks Part 6: Deploy your app Machine Amazon Web Services (Machine) Digital Ocean (Machine) docker-machine active docker-machine config docker-machine create docker-machine env docker-machine help docker-machine inspect docker-machine ip docker-machine kill docker-machine ls docker-machine provision docker-machine regenerate-certs docker-machine restart docker-machine rm docker-machine scp docker-machine ssh docker-machine start docker-machine status docker-machine stop docker-machine upgrade docker-machine url Driver options and operating system defaults (Machine) Drivers overview (Machine) Exoscale (Machine) Generic (Machine) Get started with a local VM (Machine) Google Compute Engine (Machine) IBM Softlayer (Machine) Install Machine Machine Machine CLI overview Machine command-line completion Machine concepts and help Machine overview Microsoft Azure (Machine) Microsoft Hyper-V (Machine) Migrate from Boot2Docker to Machine OpenStack (Machine) Oracle VirtualBox (Machine) Provision AWS EC2 instances (Machine) Provision Digital Ocean Droplets (Machine) Provision hosts in the cloud (Machine) Rackspace (Machine) VMware Fusion (Machine) VMware vCloud Air (Machine) VMware vSphere (Machine) Notary Client configuration (Notary) Common Server and signer configurations (Notary) Getting started with Notary Notary changelog Notary configuration files Running a Notary service Server configuration (Notary) Signer configuration (Notary) Understand the service architecture (Notary) Use the Notary client
characters

Compose 支持兩種共享通用配置的方法:

  1. 擴(kuò)展整個(gè)撰寫文件使用多個(gè)組合文件

  1. 擴(kuò)展個(gè)人服務(wù)大extends場(chǎng)域

多重合成文件

使用多個(gè)組合文件可以使您為不同的環(huán)境或不同的工作流自定義組合應(yīng)用程序。

理解多重組合文件

默認(rèn)情況下,撰寫讀取兩個(gè)文件,docker-compose.yml還有一個(gè)可選的docker-compose.override.yml檔案。根據(jù)慣例,docker-compose.yml包含基本配置。正如其名稱所暗示的那樣,覆蓋文件可以包含對(duì)現(xiàn)有服務(wù)或全新服務(wù)的配置重寫。

如果在兩個(gè)文件中都定義了服務(wù),則使用添加和覆蓋配置.

若要使用多個(gè)覆蓋文件或具有不同名稱的重寫文件,可以使用-f選項(xiàng)指定文件列表。按照命令行中指定的順序編寫合并文件。docker-compose命令引用有關(guān)使用-f

使用多個(gè)配置文件時(shí),必須確保文件中的所有路徑相對(duì)于基本組合文件。這是必需的,因?yàn)橹貙懳募灰欢ㄊ怯行У慕M合文件。覆蓋文件可以包含小的配置片段。跟蹤服務(wù)的哪個(gè)片段相對(duì)于哪個(gè)路徑比較困難和混亂,因此,為了使路徑更容易理解,必須相對(duì)于基文件定義所有路徑。

用例

在本節(jié)中,有兩個(gè)用于多個(gè)組合文件的常用用例:為不同的環(huán)境更改一個(gè)組合應(yīng)用程序,以及對(duì)一個(gè)復(fù)合應(yīng)用程序運(yùn)行管理任務(wù)。

不同環(huán)境

多文件的常見用例是為類似生產(chǎn)環(huán)境(可能是生產(chǎn),分段或CI)更改開發(fā)撰寫應(yīng)用程序。為了支持這些差異,你可以將你的 Compose 配置分成幾個(gè)不同的文件:

從一個(gè)基本文件開始,它定義了服務(wù)的規(guī)范配置。

Docker-Compose.yml

web:
  image: example/my_web_app:latest
  links:    - db    - cache

db:
  image: postgres:latest

cache:
  image: redis:latest

在此示例中,開發(fā)配置向主機(jī)公開了一些端口,將我們的代碼作為卷裝入,并構(gòu)建 Web 圖像。

docker-compose.override.yml

web:
  build: .
  volumes:    - '.:/code'
  ports:    - 8883:80
  environment:
    DEBUG: 'true'db:
  command: '-d'
  ports:    - 5432:5432cache:
  ports:    - 6379:6379

當(dāng)你運(yùn)行的時(shí)候docker-compose up它自動(dòng)讀取重寫。

現(xiàn)在,在生產(chǎn)環(huán)境中使用 Compose 應(yīng)用程序?qū)?huì)很好。因此,創(chuàng)建另一個(gè)覆蓋文件(可能存儲(chǔ)在不同的 git 倉庫或由不同的團(tuán)隊(duì)管理)。

Docker-Compose.prod.yml

web:
  ports:    - 80:80
  environment:
    PRODUCTION: 'true'cache:
  environment:
    TTL: '500'

要使用此產(chǎn)品組合文件進(jìn)行部署,可以運(yùn)行

docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

這將使用docker-compose.ymldocker-compose.prod.yml(但不包括開發(fā)配置docker-compose.override.yml)中的配置部署所有三個(gè)服務(wù)。

有關(guān)產(chǎn)品中的 Compose 的更多信息,請(qǐng)參閱產(chǎn)品。

管理任務(wù)

另一個(gè)常見的用例是針對(duì)組合應(yīng)用程序中的一個(gè)或多個(gè)服務(wù)運(yùn)行臨時(shí)或管理任務(wù)。此示例演示運(yùn)行數(shù)據(jù)庫備份。

Docker-Compose.yml 開始

web:
  image: example/my_web_app:latest
  links:    - db

db:
  image: postgres:latest

docker-compose.admin.yml 中添加一個(gè)新服務(wù)來運(yùn)行數(shù)據(jù)庫導(dǎo)出或備份。

dbadmin:
  build: database_admin/
  links:    - db

開始正常的環(huán)境運(yùn)行docker-compose up -d。要運(yùn)行數(shù)據(jù)庫備份,也要包含docker-compose.admin.yml

docker-compose -f docker-compose.yml -f docker-compose.admin.yml \
    run dbadmin db-backup

擴(kuò)展服務(wù)

注意extends關(guān)鍵字在早期的 Compose 文件格式中支持到 Compose 文件版本2.1(請(qǐng)參閱v1中的擴(kuò)展和第2版中的擴(kuò)展),但在 Compose 版本3.x中不受支持。請(qǐng)參閱第3版的添加和刪除鍵摘要以及有關(guān)如何升級(jí)的信息。請(qǐng)參閱 moby / moby#31101 以關(guān)注extends在未來版本中以某種形式添加支持的可能性。

Docker Compose 的extends關(guān)鍵字可以在不同文件之間共享通用配置,甚至可以完全共享不同的項(xiàng)目。如果您有多個(gè)服務(wù)可以重復(fù)使用一組通用配置選項(xiàng),則擴(kuò)展服務(wù)很有用。使用extends您可以在一個(gè)地方定義一套通用的服務(wù)選項(xiàng),并從任何地方引用它。

記住linksvolumes_fromdepends_on從不使用extends服務(wù)之間共享。這些例外存在以避免隱式依賴性; 你總是本地定義linksvolumes_from。這可以確保在讀取當(dāng)前文件時(shí),服務(wù)之間的依賴關(guān)系清晰可見。在本地定義這些也確保對(duì)引用文件的更改不會(huì)破壞任何內(nèi)容。

理解擴(kuò)展配置

中定義任何服務(wù)時(shí)docker-compose.yml,您可以聲明您正在擴(kuò)展如下的另一個(gè)服務(wù):

web:  extends:
    file: common-services.yml
    service: webapp

此指令將編寫為重用webapp中定義的服務(wù)。common-services.yml檔案。假設(shè)common-services.yml看起來是這樣的:

webapp:
  build: .
  ports:    - "8000:8000"
  volumes:    - "/data"

在這種情況下,您將得到完全相同的結(jié)果,就像您編寫docker-compose.yml用同樣的build,portsvolumes直接定義在web.

您可以進(jìn)一步在本地定義(或重新定義)配置docker-compose.yml

web:  extends:
    file: common-services.yml
    service: webapp
  environment:    - DEBUG=1
  cpu_shares: 5important_web:  extends: web
  cpu_shares: 10

您還可以編寫其他服務(wù)并鏈接web向他們提供服務(wù):

web:  extends:
    file: common-services.yml
    service: webapp
  environment:    - DEBUG=1
  cpu_shares: 5
  links:    - db
db:
  image: postgres

用例

當(dāng)您有多個(gè)具有公共配置的服務(wù)時(shí),擴(kuò)展單個(gè)服務(wù)非常有用。下面的示例是一個(gè)包含兩個(gè)服務(wù)的撰寫應(yīng)用程序:一個(gè) Web 應(yīng)用程序和一個(gè)隊(duì)列工作程序。這兩個(gè)服務(wù)使用相同的代碼庫,并共享許多配置選項(xiàng)。

common.yml 中我們定義了通用配置:

app:
  build: .
  environment:
    CONFIG_FILE_PATH: /code/config
    API_KEY: xxxyyy
  cpu_shares: 5

docker-compose.yml ,我們定義了使用通用配置的具體服務(wù):

webapp:  extends:
    file: common.yml
    service: app
  command: /code/run_web_app
  ports:    - 8080:8080
  links:    - queue    - db

queue_worker:  extends:
    file: common.yml
    service: app
  command: /code/run_worker
  links:    - queue

添加和覆蓋配置

將副本配置從原始服務(wù)復(fù)制到本地服務(wù)。如果在原始服務(wù)和本地服務(wù)中都定義了配置選項(xiàng),則本地值取代或擴(kuò)展原始價(jià)值。

對(duì)于單值選項(xiàng)image,command或者mem_limit,新值替換舊值。

# original service
command: python app.py

# local service
command: python otherapp.py

# result
command: python otherapp.py

buildimage在撰寫文件版本1 如屬buildimage,使用時(shí)編寫文件格式的版本1,如果在原始服務(wù)中定義了另一個(gè)選項(xiàng),則使用本地服務(wù)中的一個(gè)選項(xiàng)將導(dǎo)致組合放棄另一個(gè)選項(xiàng)。 例如,如果原始服務(wù)定義image: webapp本地服務(wù)定義build: .則結(jié)果服務(wù)將具有build: .而不是image選擇。 這是因?yàn)?code>build和image不能在版本1文件中一起使用。

對(duì)于多值的選項(xiàng) ports,expose,external_linksdnsdns_search,和tmpfs,撰寫會(huì)連接兩組的值:

# original service
expose:  - "3000"# local service
expose:  - "4000"  - "5000"# result
expose:  - "3000"  - "4000"  - "5000"

environment,labelsvolumesdevices情況下,撰寫“合并”的條目連同本地定義的值取的優(yōu)先級(jí):

# original service
environment:  - FOO=original  - BAR=original

# local service
environment:  - BAR=local  - BAZ=local

# result
environment:  - FOO=original  - BAR=local  - BAZ=local

撰寫文件

  • 用戶指南

  • 安裝組合

  • 開始

  • 從Django開始

  • 從Rails開始

  • 從WordPress開始

  • 命令行引用

  • 合成文件引用

Previous article: Next article: