Skip to content

container-compose does not like Docker Compose-style environment config #65

@purp

Description

@purp

Hi. New guy here. I have a philosophical question, and depending on the answer I might have a bug report.

Q: "Strictly Docker Compatible" or "Help Folks Migrate"?

Spelled out more fully, the philosophical question is: Are we trying to be strictly interoperable with Docker Compose style YAML files, or are we trying to make it easier to migrate to Apple containers by providing a "docker-composer-like" tool? A more concrete related question is: are we okay if container-compose requires Docker Compose-incompatible changes to compose files?

An Incompatible Bit

Thus far, I've identified one incompatibility between docker-compose and container-compose: how we handle environment settings. A simple example: setting some overrides for the nginx:alpine container. Here's what that looks like in Docker Compose style:

services:
  nginx:
    container_name: nginx
    restart: always
    image: nginx:alpine
    environment:
      - NGINX_ENTRYPOINT_LOCAL_RESOLVERS="1"
      - NGINX_ENVSUBST_TEMPLATE_DIR="/etc/nginx/snippets"
      - NGINX_ENVSUBST_OUTPUT_DIR="/etc/nginx"
    ports:
      - "80:80"
      - "443:443"

... which gives you this love note from container-compose:

Error: typeMismatch(Yams.Node.Mapping, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "services", intValue: nil), _DictionaryCodingKey(stringValue: "nginx", intValue: nil), CodingKeys(stringValue: "environment", intValue: nil)], debugDescription: "Expected to decode Mapping but found Node instead.", underlyingError: nil))

... which is fixed by this (environment only, all else is same):

    environment:
      NGINX_ENTRYPOINT_LOCAL_RESOLVERS: "1"
      NGINX_ENVSUBST_TEMPLATE_DIR: "/etc/nginx/snippets"
      NGINX_ENVSUBST_OUTPUT_DIR: "/etc/nginx"

I'm fine with the change; as I said, I'm migrating so I'm not trying to maintain Docker Compose compatibility. But if the project's philosophy is eventual strict compatibility, then this is a bug.

Why Do I Care?

I'm just starting to migrate from Docker to Apple containers, and I'm working to adopt container-compose as the mechanism for this. Thus far, I've been refusing to give up and working around some of the incomplete functionality (like network subnets) and I'm ready to lean in and help make it better in places. I tend towards test-driven development, so I'm spending time understanding what we've got so far and how it's tested. I also write a lot of markdown, so I tend to use it when I can.

At the moment, I'm working on cleaning up some small things like where container-compose emits a hard-coded "docker-compose.yml" string, as well as many comments and a bit of the README where we refer to these, and the pedant in me wanted to be sure I changed things to the right way we should think and talk about them. And here we are.

It also felt like a small bit of good I could do while adopting, and it feels like it's related to a few issues like #33 , #36, and maybe #63. So I'm adding a test that breaks if we talk about the wrong filename, and that incidentally tests that we're using the right file with --file ... so we'll have a test soon, then I'll look at cherrypicking some of #36 or #63 into a PR to fix it.

Thanks for reading. I'm usually more terse. This felt like it needed details, so I added some.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions