[][src]Crate compose_yml

Support for reading and writing docker-compose.yml files.

The docker-compose.yml format is suprisingly complex, with support for multiple ways of representing the same data. This library attemps to provide a single, consistent and type-safe representation of everything found in a docker-compose.yml version 2 file.

Here's an example of one property, build, being represented in two different ways, and how we normalize it:

use std::str::FromStr;
use compose_yml::v2 as dc;

let yaml = r#"---

version: "2"
      context: "./app1"
      dockerfile: "Dockerfile-alt"

    build: "./app2"


let file = dc::File::from_str(yaml).unwrap();

let app1 = file.services.get("app1").unwrap();
let build1 = app1.build.as_ref().unwrap();
assert_eq!(build1.context, dc::value(dc::Context::new("./app1")));

// We automatically convert all different `build:` syntaxes
// to be consistent.
let app2 = file.services.get("app2").unwrap();
let build2 = app2.build.as_ref().unwrap();
assert_eq!(build2.context, dc::value(dc::Context::new("./app2")));

An interesting place to start browsing this documentation is docker_compose::v2::Service. You can drill down into other fields from there.



We provide fancy error-handling support thanks to the error_chain crate. The primary advantage of error_chain is that it provides support for backtraces. The secondary advantage of this crate is that it gives us nice, structured error types.


Support for the docker-compose.yml version 2 file format.