Skip to content

fix: add --name and --detach flags to container options parser - #6026

Open
mango766 wants to merge 1 commit into
nektos:masterfrom
mango766:fix/container-options-name
Open

fix: add --name and --detach flags to container options parser#6026
mango766 wants to merge 1 commit into
nektos:masterfrom
mango766:fix/container-options-name

Conversation

@mango766

Copy link
Copy Markdown

Fixes #5929

Problem

When using --name or -d in the options field of service containers (which is valid in GitHub Actions), act fails with:

Cannot parse container options: '--name my-redis-container': 'unknown flag: --name'

This happens because the container options flag parser in docker_cli.go doesn't register these flags, so pflag rejects them as unknown.

Fix

Added --name and --detach/-d to the flag set in addFlags(). These flags are accepted for compatibility with docker create/docker run but the values are not used by act, which manages container names and lifecycle internally. This follows the same pattern as --rm, which is already accepted but unused.

Example workflow that now works

services:
  redis:
    image: redis:latest
    ports:
      - 9003:6379
    options: --name my-redis-container

The container options parser used by service definitions was missing
support for the --name and --detach/-d flags, causing workflows with
`options: --name my-container` to fail with:

  Cannot parse container options: '--name my-redis-container':
  'unknown flag: --name'

These flags are accepted for compatibility with docker create/run but
are not used by act, which manages container names and lifecycle
internally. This matches how --rm is already handled.

Fixes nektos#5929

@themavik themavik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: test body for 6026

@themavik themavik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: --name and --detach parse but are ignored; anyone expecting docker parity might think the container is actually named or detached鈥攚orth spelling out the no-op in the flag description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--name not supported in service docker container options when using act

2 participants