[GH-ISSUE #2003] act does not create separate containers for matrix builds with reusable workflows #963

Closed
opened 2026-03-01 21:47:45 +03:00 by kerem · 1 comment
Owner

Originally created by @Andy4495 on GitHub (Sep 11, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/2003

Bug report info

act version:            0.2.50
GOOS:                   darwin
GOARCH:                 amd64
NumCPU:                 8
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
	$HOME/.docker/run/docker.sock
Config files:           
	/Users/andy/.actrc:
		-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest
		-P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.21.0
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.50
		DefaultGODEBUG:       panicnil=1
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               amd64
		GOOS:                 darwin
		GOAMD64:              v1
Docker Engine:
	Engine version:        24.0.5
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Docker Desktop
	OS type:               linux
	OS version:            
	OS arch:               x86_64
	OS kernel:             5.15.49-linuxkit-pr
	OS CPU:                4
	OS memory:             7859 MB
	Security options:
		name=seccomp,profile=unconfined
		name=cgroupns

Command used with act

act -j call-reusable-workflow

Describe issue

When using act with reusable workflows called with a matrix strategy, act does not create separate docker containers for each matrix combination; it tries to run them all in the same container which generates an error (see log output below).

If I run the same matrix strategy in a standalone workflow, act creates a separate docker container for each matrix combination and the workflow runs successfully.

https://github.com/Andy4495/act-workflow-test

Workflow content

# The "caller" workflow
name: Call Reusable Workflow

on: 
  push:
  workflow_dispatch:

jobs:
  call-reusable-workflow: 
    strategy:
      matrix:
        include:
          - message: test1
          - message: test2
          - message: test3
          - message: test4
 
    name: call-reusable-workflow
    uses: Andy4495/act-workflow-test/.github/workflows/reusable-flow.yml@main
    with:
      message: ${{ matrix.message }}

---

# The "called" (reusable) workflow
name: reusable-workflow

on: 
  workflow_call:
    inputs:
      message:
        description: Message to display
        required: true
        type: string

jobs:
  reusable-workflow: 
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Print the message
        run: |
          echo Test reusable workflow ${{ inputs.message }}

Relevant log output

Error: failed to create container: 'Error response from daemon: Conflict. The container name "/act-call-reusable-workflow-reusable-workflow-reusable-workflow-c7535ef5a84abfd1f2412cceca72bd226072ccb44b16a59787972320d9cb1a2d" is already in use by container "d0baad951ea56daf6bd3097af098d08b22d726733e0e4a54120fe40c357874a0". You have to remove (or rename) that container to be able to reuse that name.'

Additional information

As mentioned above, this works fine with standalone workflows.

Originally created by @Andy4495 on GitHub (Sep 11, 2023). Original GitHub issue: https://github.com/nektos/act/issues/2003 ### Bug report info ```plain text act version: 0.2.50 GOOS: darwin GOARCH: amd64 NumCPU: 8 Docker host: DOCKER_HOST environment variable is not set Sockets found: /var/run/docker.sock $HOME/.docker/run/docker.sock Config files: /Users/andy/.actrc: -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest -P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04 -P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04 Build info: Go version: go1.21.0 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.50 DefaultGODEBUG: panicnil=1 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: amd64 GOOS: darwin GOAMD64: v1 Docker Engine: Engine version: 24.0.5 Engine runtime: runc Cgroup version: 2 Cgroup driver: cgroupfs Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Docker Desktop OS type: linux OS version: OS arch: x86_64 OS kernel: 5.15.49-linuxkit-pr OS CPU: 4 OS memory: 7859 MB Security options: name=seccomp,profile=unconfined name=cgroupns ``` ### Command used with act ```sh act -j call-reusable-workflow ``` ### Describe issue When using act with reusable workflows called with a matrix strategy, act does not create separate docker containers for each matrix combination; it tries to run them all in the same container which generates an error (see log output below). If I run the same matrix strategy in a standalone workflow, act creates a separate docker container for each matrix combination and the workflow runs successfully. ### Link to GitHub repository https://github.com/Andy4495/act-workflow-test ### Workflow content ```yml # The "caller" workflow name: Call Reusable Workflow on: push: workflow_dispatch: jobs: call-reusable-workflow: strategy: matrix: include: - message: test1 - message: test2 - message: test3 - message: test4 name: call-reusable-workflow uses: Andy4495/act-workflow-test/.github/workflows/reusable-flow.yml@main with: message: ${{ matrix.message }} --- # The "called" (reusable) workflow name: reusable-workflow on: workflow_call: inputs: message: description: Message to display required: true type: string jobs: reusable-workflow: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Print the message run: | echo Test reusable workflow ${{ inputs.message }} ``` ### Relevant log output ```sh Error: failed to create container: 'Error response from daemon: Conflict. The container name "/act-call-reusable-workflow-reusable-workflow-reusable-workflow-c7535ef5a84abfd1f2412cceca72bd226072ccb44b16a59787972320d9cb1a2d" is already in use by container "d0baad951ea56daf6bd3097af098d08b22d726733e0e4a54120fe40c357874a0". You have to remove (or rename) that container to be able to reuse that name.' ``` ### Additional information As mentioned above, this works fine with standalone workflows.
kerem 2026-03-01 21:47:45 +03:00
  • closed this issue
  • added the
    kind/bug
    label
Author
Owner

@Andy4495 commented on GitHub (Sep 21, 2023):

I found the problem and it looks like the fix is pretty simple.

The container name generated for reusable workflows is not unique, so each matrix run was trying to use the same container. The code was using the non-unique caller job name instead of the unique name (with the -1, -2, ... appended).

So the fix should be in runner/run_context.go function String().

Change this:

name = fmt.Sprintf("%s/%s", rc.caller.runContext.Run.JobID, name)

To this:

name = fmt.Sprintf("%s/%s", rc.caller.runContext.Name, name)

I'll open a pull request after I run a few more tests.

<!-- gh-comment-id:1728700799 --> @Andy4495 commented on GitHub (Sep 21, 2023): I found the problem and it looks like the fix is pretty simple. The container name generated for reusable workflows is not unique, so each matrix run was trying to use the same container. The code was using the non-unique caller job name instead of the unique name (with the -1, -2, ... appended). So the fix should be in `runner/run_context.go` function `String()`. Change this: name = fmt.Sprintf("%s/%s", rc.caller.runContext.Run.JobID, name) To this: name = fmt.Sprintf("%s/%s", rc.caller.runContext.Name, name) I'll open a pull request after I run a few more tests.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#963
No description provided.