博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Overview of Docker Compose
阅读量:4031 次
发布时间:2019-05-24

本文共 5247 字,大约阅读时间需要 17 分钟。

Overview of Docker Compose

Compose is a tool for defining and running multi-container Docker applications.With Compose, you use a Compose file to configure your application’s services.Then, using a single command, you create and start all the servicesfrom your configuration. To learn more about all the features of Composesee .

Compose is great for development, testing, and staging environments, as well asCI workflows. You can learn more about each case in.

Using Compose is basically a three-step process.

  1. Define your app’s environment with a Dockerfile so it can bereproduced anywhere.
  2. Define the services that make up your app in docker-compose.yml sothey can be run together in an isolated environment.
  3. Lastly, run docker-compose up and Compose will start and run your entire app.

A docker-compose.yml looks like this:

web:  build: .  ports:   - "5000:5000"  volumes:   - .:/code  links:   - redisredis:  image: redis

For more information about the Compose file, see the

Compose has commands for managing the whole lifecycle of your application:

  • Start, stop and rebuild services
  • View the status of running services
  • Stream the log output of running services
  • Run a one-off command on a service

Compose documentation

Features

The features of Compose that make it effective are:

Multiple isolated environments on a single host

Compose uses a project name to isolate environments from each other. You can usethis project name to:

  • on a dev host, to create multiple copies of a single environment (ex: you wantto run a stable copy for each feature branch of a project)
  • on a CI server, to keep builds from interfering with each other, you can setthe project name to a unique build number
  • on a shared host or dev host, to prevent different projects which may use thesame service names, from interfering with each other

The default project name is the basename of the project directory. You can seta custom project name by using the or the.

Preserve volume data when containers are created

Compose preserves all volumes used by your services. When docker-compose upruns, if it finds any containers from previous runs, it copies the volumes fromthe old container to the new container. This process ensures that any datayou’ve created in volumes isn’t lost.

Only recreate containers that have changed

Compose caches the configuration used to create a container. When yourestart a service that has not changed, Compose re-uses the existingcontainers. Re-using containers means that you can make changes to yourenvironment very quickly.

Variables and moving a composition between environments

Compose supports variables in the Compose file. You can use these variablesto customize your composition for different environments, or different users.See for moredetails.

You can extend a Compose file using the extends field or by creating multipleCompose files. See for more details.

Common Use Cases

Compose can be used in many different ways. Some common use cases are outlinedbelow.

Development environments

When you’re developing software, the ability to run an application in anisolated environment and interact with it is crucial. The Compose commandline tool can be used to create the environment and interact with it.

The provides a way to document and configureall of the application’s service dependencies (databases, queues, caches,web service APIs, etc). Using the Compose command line tool you can createand start one or more containers for each dependency with a single command(docker-compose up).

Together, these features provide a convenient way for developers to getstarted on a project. Compose can reduce a multi-page “developer gettingstarted guide” to a single machine readable Compose file and a few commands.

Automated testing environments

An important part of any Continuous Deployment or Continuous Integration processis the automated test suite. Automated end-to-end testing requires anenvironment in which to run tests. Compose provides a convenient way to createand destroy isolated testing environments for your test suite. By defining the fullenvironment in a you can create and destroy theseenvironments in just a few commands:

$ docker-compose up -d$ ./run_tests$ docker-compose stop$ docker-compose rm -f

Single host deployments

Compose has traditionally been focused on development and testing workflows,but with each release we’re making progress on more production-oriented features.You can use Compose to deploy to a remote Docker Engine. The Docker Engine maybe a single instance provisioned with or an entire cluster.

For details on using production-oriented features, see in this documentation.

Release Notes

To see a detailed list of changes for past and current releases of DockerCompose, please refer to the.

Getting help

Docker Compose is under active development. If you need help, would like tocontribute, or simply want to talk about the project with like-mindedindividuals, we have a number of open channels for communication.

  • To report bugs or file feature requests: please use the .

  • To talk about the project with people in real time: please join the#docker-compose channel on freenode IRC.

  • To contribute code or documentation changes: please submit a .

For more information and resources, please visit the .

转载地址:http://nnhbi.baihongyu.com/

你可能感兴趣的文章
标记一下
查看>>
一个ahk小函数, 实现版本号的比较
查看>>
IP报文格式学习笔记
查看>>
autohotkey快捷键显示隐藏文件和文件扩展名
查看>>
Linux中的进程
查看>>
学习python(1)——环境与常识
查看>>
学习设计模式(3)——单例模式和类的成员函数中的静态变量的作用域
查看>>
自然计算时间复杂度杂谈
查看>>
当前主要目标和工作
查看>>
POJ 2363 Blocks(我的水题之路——立方体体积和表面积,暴力)
查看>>
POJ 2390 Bank Interest(我的水题之路——double和floa计算差别)
查看>>
POJ 2459 Feed Accounting(我的水题之路——英文题啊!!!)
查看>>
POJ 2470 Ambiguous permutation(我的水题之路——位置和值的队列)
查看>>
POJ 2498 StuPId(我的水题之路——from back to front- -!)
查看>>
POJ 2535 Very Simple Problem(我的水题之路——看错题)
查看>>
POJ 2538 WERTYU(我的水题之路——键盘错位)
查看>>
POJ 2551 Ones(我的水题之路——重点,末尾有几个1)
查看>>
POJ 2562 Primary Arithmetic(我的水题之路——模拟加法进位)
查看>>
POJ 2575 Jolly Jumpers(我的水题之路——数组绝对差值为1到n-1)
查看>>
POJ 2578 Keep on Truckin'(我的水题之路——谁先大于168)
查看>>