Docker 编辑支持
作者: josegonzalez创建于 2022年4月9日更新于 2026年8月30日
标签merge-level: minordifficulty: mediumstatus: has planplugin: buildersplugin: schedulersestimate: 10h
Feature description Over the years, there have been a few tickets for Docker compose: - #4953 - #4704 - #3261 - #1033 As well as an early MR attempt: #1596 I recently - last night when I couldn't sleep - reinvestigated potential support for Compose, and I think we can do it now based on our work with the schedulers plugin as well as the evolution of the compose spec. Here is how it would work: ## New plugins ### New builder-compose plugin The builder-compose plugin will not auto-detect, and is opt-in. Users will have to do select it to use it. shell dokku builder:set selected $APP compose During the build process, we will do the following: - Fail if there is any use of relative paths in volumes. - Remove any services with the label `com.dokku.compose=false`. - We could also allow folks to specify a `profile` that we use for builds and such. - Rewrite the `image` for any services with a `build` directive so that the image name ends up being `dokku/$APP:latest-$PROCESS_TYPE`. - The `web` process will end up being tagged `latest`. If there are multiple with the same exact build context, they will share the same tag (with the process type being that of `web` if that is an option or whatever the first is in lexicographical order). - If there is no `web` process, an alternative label `com.dokku.primary-image=true` can be specified on a service with a `build` context. This will force that - and any others with the same build context - to be the `latest` label. This is mutually exclusive with a `web` process, and the builder will fail if both are specified. - If there is no image that ends up being latest, the builder will fail. - Add the labels dokku uses internally for tracking images/containers to all the services with a `build` directive. - Run `Docker-compose build` Dokku internals will reference the `latest` image for extracting files or anything (though usually this happens in `post-extract` early on). We should be able to specify the path to a compose file (for monorepo support) separately from selecting the builder via: shell dokku builder-compose:set $APP compose-path $SOME_PATH This will apply to both the builder and the scheduler. We can also set buildx support on: shell dokku builder-compose:set $APP buildx true Potential issue is that we can't read _and_ write the yaml file in Golang. I've opened an issue based on this [here](https://GitHub.com/compose-spec/compose-go/issues/246), so maybe I'm wrong and I'll be able to do this in Go. If not, we'll do the parsing/validation logic in a small Python script. ### New scheduler-compose plugin Users will need to opt into this scheduler. shell dokku scheduler:set selected $APP compose This one will take the parsed/validated compose yaml file and run Docker compose up. A user can specify a compose context to schedule apps to ACI or ECS via a scheduler-compose property: ```shell dokku scheduler-compose:set $APP context $CONTEXT …
内容来源: dokku/dokku