WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Setting top level name: in compose file to an environment variable fails #1319

@jameeters

Description

@jameeters

Describe the bug
Attempting to set the top level name: attribute in a compose file to an environment variable results in an error, even when the same variable is properly applied elsewhere in the file.

I encountered this on macos, and could not reproduce it on my linux machine, so it may be specific to macos.
I'll include details for both machines below.

To Reproduce

  1. Create docker-compose.yml:
version: "3.8"
name: ${INSTANCE_NAME}
services:
  postgres:
    container_name: "${INSTANCE_NAME}_pg"
    image: "postgres:16-bullseye"
  1. create .env:
export INSTANCE_NAME='ALICE'
  1. source .env
  2. podman compose up

Expected behavior
On linux, podman compose up gives:

>>>> Executing external compose provider "/usr/bin/podman-compose". Please refer to the documentation for details. <<<<

podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.9.3
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=ALICE', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'ALICE_default']
podman create --name=ALICE_pg --label io.podman.compose.config-hash=3492c3437da7e8a60e214621247c689574fa3069d57a4fb80c1e7c7a9a3c8831 --label io.podman.compose.project=ALICE --label io.podman.compose.version=1.0.6 --label [email protected] --label com.docker.compose.project=ALICE --label com.docker.compose.project.working_dir=/home/james/Documents/podman_test --label com.docker.compose.project.config_files=docker-compose.yml --label com.docker.compose.container-number=1 --label com.docker.compose.service=postgres --net ALICE_default --network-alias postgres postgres:16-bullseye
cd846e8441016be887c9d6896bcc135f82d5f85219a585296b77d72e190e78a3
exit code: 0
podman start -a ALICE_pg

(container output omitted)

Actual behavior
On macos, podman compose up produces:

>>>> Executing external compose provider "/opt/homebrew/bin/podman-compose". Please see podman-compose(1) for how to disable this message. <<<<

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 944, in assert_cnt_nets
    await compose.podman.output([], "network", ["exists", net_name])
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 1572, in output
    raise subprocess.CalledProcessError(p.returncode, " ".join(cmd_ls), stderr_data)
subprocess.CalledProcessError: Command 'podman network exists __default' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/bin/podman-compose", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 4256, in main
    asyncio.run(async_main())
    ~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 4252, in async_main
    await podman_compose.run()
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 2072, in run
    retcode = await cmd(self, args)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 3170, in compose_up
    podman_args = await container_to_args(compose, cnt, detached=False, no_deps=args.no_deps)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 1182, in container_to_args
    await assert_cnt_nets(compose, cnt)
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 949, in assert_cnt_nets
    await compose.podman.output([], "network", args)
  File "/opt/homebrew/Cellar/podman-compose/1.5.0/libexec/lib/python3.13/site-packages/podman_compose.py", line 1572, in output
    raise subprocess.CalledProcessError(p.returncode, " ".join(cmd_ls), stderr_data)
subprocess.CalledProcessError: Command 'podman network create --label io.podman.compose.project=_ --label com.docker.compose.project=_ __default' returned non-zero exit status 125.
Error: executing /opt/homebrew/bin/podman-compose up: exit status 1

Environment:

  • mac (problematic)
    • podman version: 5.6.2
    • podman compose version: 1.5.0
    • OS: macos sequoia 15.6.1
  • Linux (working as expected)
    • podman version: 4.9.3
    • podman compose version: 1.0.6
    • OS: Ubuntu 24.04.3 LTS

If there's anything else I can provide I'll be happy to help. Thanks for all your efforts on this project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions