不喜欢广告? 无广告 今天

Docker Compose YAML Formatter

数据开发人员
广告 移除?

排版选项

广告 移除?

指导

Docker Compose YAML Formatter

Docker Compose YAML Formatter

Paste a docker-compose.yml and instantly get a clean, consistently formatted file with services, networks, and volumes ordered the way Docker Compose conventions expect. The formatter validates the file against the modern Compose Spec, flags deprecated keys like the old top-level version field or legacy links, and warns about unknown service options before they cause runtime failures.

如何使用

  1. 将您的 docker-compose.yml into the input area, or click one of the example links to load a sample stack.
  2. Pick a key order — Compose convention sorts services in the order Compose users expect (image, restart, environment, ports, volumes, …), Alphabetical sorts strictly A-Z, or Preserve keeps your original order.
  3. Choose 2 or 4 space indentation and toggle Compose Spec validation on or off.
  4. Read the validation panel for errors, warnings about deprecated keys, and info notices about implicit network references.
  5. Copy the result or download it as docker-compose.yml.

特征

  • Compose Spec validation – Recognizes top-level services, networks, volumes, configs, secrets, profiles, include, and extension fields (x-*); flags anything else.
  • Deprecation warnings – Highlights the legacy top-level version key, links, external_links, and v2-era resource limits that should move under deploy.resources.
  • Service-aware key ordering – Reorders each service so identifying keys (image, build, container_name) come first, runtime config (environment, ports, volumes) sits in the middle, and ops concerns (healthcheck, logging, deploy) land at the bottom.
  • Reference checks – Detects services that depend on undefined services and warns when a service uses a network that isn’t declared at the top level.
  • Service requirements – Verifies every service has at least one of image, build, extends, 或者 provider, and that restart uses one of the four valid policies.
  • Port + healthcheck sanity – Catches malformed port strings, missing target in long-form ports, and healthchecks without a test.
  • Three working examples – A Node + Postgres web app, a WordPress + MySQL + Redis stack, and a multi-service build with profiles and resource limits.
  • Local + private – All parsing, sorting, and validation runs in your browser. Your Compose file never leaves the page.

常问问题

  1. Why is the top-level version key deprecated?

    The version key was used in legacy Compose v1, v2, and v3 to select a schema for the docker-compose CLI. The current Compose Specification merged those schemas into a single, continuously evolving spec, so a version declaration no longer changes anything — recent Docker Compose releases simply ignore it and print a warning. Removing it shrinks the file and avoids confusion when readers assume v3 features are gated by the declaration.

  2. What is the Compose Specification and how does it differ from older Compose file formats?

    The Compose Specification is the open, vendor-neutral schema that replaces the per-version schemas Docker Compose used through 2020. It is maintained at github.com/compose-spec/compose-spec and is implemented by Docker Compose, Podman Compose, and other runners. Compared to v2 and v3, the spec drops the version field, makes services the only required top-level key, and absorbs Swarm-only fields like deploy as optional metadata that orchestrators may consume.

  3. Why prefer a shared network over the links keyword?

    links was inherited from Docker's pre-network era and only sets up DNS aliases between containers on the default bridge. Modern user-defined networks already give every service automatic DNS resolution by service name, support multiple isolated networks per stack, and let you control DNS aliases with the aliases option. Because of this, the Compose Spec marks links as legacy and recommends explicit network membership instead.

  4. What does each restart policy actually do?

    no never restarts the container. always restarts it whenever it stops, including after a daemon restart. on-failure restarts only when the container exits with a non-zero status, optionally bounded by a max-retries count. unless-stopped behaves like always, except a container that was manually stopped before a daemon restart stays stopped. The four values are case-sensitive strings — anything else is rejected by the Compose engine.

  5. How does Compose decide whether to pull or build an image?

    Compose looks at pull_policy, build, and image together. With pull_policy: always Compose pulls before every up. With missing or if_not_present (the default when only image is set) it pulls only if the image is absent locally. With never it never pulls. When build is present alongside image, pull_policy: build forces a rebuild and tags the result as image, while pull_policy: missing rebuilds only when the image is not yet present locally.

想要享受无广告的体验吗? 立即无广告

安装我们的扩展

将 IO 工具添加到您最喜欢的浏览器,以便即时访问和更快地搜索

添加 Chrome 扩展程序 添加 边缘延伸 添加 Firefox 扩展 添加 Opera 扩展

记分板已到达!

记分板 是一种有趣的跟踪您游戏的方式,所有数据都存储在您的浏览器中。更多功能即将推出!

广告 移除?
广告 移除?
广告 移除?

新闻角 包含技术亮点

参与其中

帮助我们继续提供有价值的免费工具

给我买杯咖啡
广告 移除?