nektos/act

Cannot bind port for MySQL service

Opened this issue ยท 4 comments

Bug report info

act version:            0.2.70
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 2
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
        /var/run/docker.sock
Config files:           
        /home/shane/.actrc:
                -P ubuntu-latest=catthehacker/ubuntu:act-latest
                -P ubuntu-22.04=catthehacker/ubuntu:act-22.04
                -P ubuntu-20.04=catthehacker/ubuntu:act-20.04
                -P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
        Go version:            go1.21.13
        Module path:           github.com/nektos/act
        Main version:          (devel)
        Main path:             github.com/nektos/act
        Main checksum:         
        Build settings:
                -buildmode:           exe
                -compiler:            gc
                -trimpath:            true
                CGO_ENABLED:          0
                GOARCH:               amd64
                GOOS:                 linux
                GOAMD64:              v1
                vcs:                  git
                vcs.revision:         3f5d34d38dec16a3c4cec1e8aab00d5f123727b2
                vcs.time:             2024-09-07T22:56:04Z
                vcs.modified:         true
Docker Engine:
        Engine version:        27.3.1
        Engine runtime:        runc
        Cgroup version:        1
        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.167.4-microsoft-standard-WSL2
        OS CPU:                2
        OS memory:             9951 MB
        Security options:
                name=seccomp,profile=unconfined

Command used with act

act -W .github/workflows/phpunit.yml

Describe issue

I expected to be able to run my PHPUnit testing workflow.

Unfortunately, when I do so I am presented with an error about port binding failing due to the port already being allocated.

It fails before the first step, when trying to set up the MySQL service. If I comment that service out, the workflow proceeds but fails later due to the missing database (note: I've only included the relevant part at start of workflow file in the 'workflow content' section, but it's a self-contained working example).

This workflow works on GitHub.

Link to GitHub repository

No response

Workflow content

name: Unit Testing

on:
  workflow_dispatch:
  push:

concurrency:
  group: cc-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:

  testing:
    name: PHPUnit ${{ matrix.php }}
    runs-on: ubuntu-latest
    timeout-minutes: 12

    strategy:
      fail-fast: true
      matrix:
        php: [ 8.3 ]
    
    services:
      mysql_testing:
        image: mysql/mysql-server:8.0
        env:
          MYSQL_DATABASE: database
          MYSQL_USER: user
          MYSQL_PASSWORD: password
          MYSQL_ROOT_PASSWORD: rootpassword
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

      - name: Verify MySQL connection
        run: |
          mysql --version
          sudo apt-get install -y mysql-client
          mysql --host 127.0.0.1 --port ${{ job.services.mysql_testing.ports['3306'] }} -uuser -ppassword -e "SHOW DATABASES"

[...]

Relevant log output

DEBU[0000] Handling container host and socket           
DEBU[0000] Defaulting container socket to DOCKER_HOST   
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
DEBU[0000] Conditional GET for notices etag=a8049100-3951-46e4-8cb7-45b8dfc2428f 
DEBU[0000] Loading environment from /home/shane/apps/maps/.env 
DEBU[0000] Loading action inputs from /home/shane/apps/maps/.input 
DEBU[0000] Loading secrets from /home/shane/apps/maps/.secrets 
DEBU[0000] Loading vars from /home/shane/apps/maps/.vars 
DEBU[0000] Evaluated matrix inclusions: map[]           
DEBU[0000] Loading workflow '/home/shane/apps/maps/.github/workflows/phpunit.yml' 
DEBU[0000] Reading workflow '/home/shane/apps/maps/.github/workflows/phpunit.yml' 
DEBU[0000] Preparing plan with all jobs                 
DEBU[0000] Using default workflow event: push           
DEBU[0000] Planning jobs for event: push                
DEBU[0000] gc: 2024-12-18 10:49:42.805880221 +1030 ACDT m=+0.004822698  module=artifactcache
DEBU[0000] Plan Stages: [0xc00045be48]                  
DEBU[0000] Stages Runs: [PHPUnit ${{ matrix.php }}]     
DEBU[0000] Job.Name: PHPUnit ${{ matrix.php }}          
DEBU[0000] Job.RawNeeds: {0 0    <nil> []    0 0}       
DEBU[0000] Job.RawRunsOn: {8 0 !!str ubuntu-latest  <nil> []    15 14} 
DEBU[0000] Job.Env: {0 0    <nil> []    0 0}            
DEBU[0000] Job.If: {0 0  success()  <nil> []    0 0}    
DEBU[0000] Job.Steps: Checkout code                     
DEBU[0000] Job.Steps: Setup PHP                         
DEBU[0000] Job.Steps: Confirm PHP version               
DEBU[0000] Job.Steps: Prepare the environment           
DEBU[0000] Job.Steps: Verify MySQL connection           
DEBU[0000] Job.Steps: Validate composer.json and composer.lock 
DEBU[0000] Job.Steps: Cache Composer packages           
DEBU[0000] Job.Steps: Install Composer dependencies     
DEBU[0000] Job.Steps: Generate application key          
DEBU[0000] Job.Steps: Clear caches                      
DEBU[0000] Job.Steps: Directory Permissions             
DEBU[0000] Job.Steps: PHPUnit test suite                
DEBU[0000] Job.Steps: Upload app logs                   
DEBU[0000] Job.TimeoutMinutes: 12                       
DEBU[0000] Job.Services: map[mysql_testing:0xc0004badc0] 
DEBU[0000] Job.Strategy: &{false 0 true  {4 0 !!map   <nil> [0xc000376fa0 0xc000377040]    21 9}} 
DEBU[0000] Job.RawContainer: {0 0    <nil> []    0 0}   
DEBU[0000] Job.Defaults.Run.Shell:                      
DEBU[0000] Job.Defaults.Run.WorkingDirectory:           
DEBU[0000] Job.Outputs: map[]                           
DEBU[0000] Job.Uses:                                    
DEBU[0000] Job.With: map[]                              
DEBU[0000] Job.Result:                                  
DEBU[0000] Job.Strategy.FailFast: false                 
DEBU[0000] Job.Strategy.MaxParallel: 0                  
DEBU[0000] Job.Strategy.FailFastString: true            
DEBU[0000] Job.Strategy.MaxParallelString:              
DEBU[0000] Job.Strategy.RawMatrix: {4 0 !!map   <nil> [0xc000376fa0 0xc000377040]    21 9} 
DEBU[0000] Loading revision from git directory          
DEBU[0000] Found revision: 85993cc11d108fb8864c151dd805d5fc0aaa65f5 
DEBU[0000] HEAD points to '85993cc11d108fb8864c151dd805d5fc0aaa65f5' 
DEBU[0000] using github ref: refs/heads/fix-dusk-tests  
DEBU[0000] Found revision: 85993cc11d108fb8864c151dd805d5fc0aaa65f5 
DEBU[0000] expression 'PHPUnit ${{ matrix.php }}' rewritten to 'format('PHPUnit {0}', matrix.php)' 
DEBU[0000] evaluating expression 'format('PHPUnit {0}', matrix.php)' 
DEBU[0000] expression 'format('PHPUnit {0}', matrix.php)' evaluated to '%!t(string=PHPUnit )' 
DEBU[0000] Loading revision from git directory          
DEBU[0000] Found revision: 85993cc11d108fb8864c151dd805d5fc0aaa65f5 
DEBU[0000] HEAD points to '85993cc11d108fb8864c151dd805d5fc0aaa65f5' 
DEBU[0000] using github ref: refs/heads/fix-dusk-tests  
DEBU[0000] Found revision: 85993cc11d108fb8864c151dd805d5fc0aaa65f5 
DEBU[0000] true                                         
DEBU[0000] Job Matrices: [map[php:8.3]]                 
DEBU[0000] Runner Matrices: map[]                       
DEBU[0000] Final matrix after applying user inclusions '[map[php:8.3]]' 
DEBU[0000] Loading revision from git directory          
DEBU[0000] Found revision: 85993cc11d108fb8864c151dd805d5fc0aaa65f5 
DEBU[0000] HEAD points to '85993cc11d108fb8864c151dd805d5fc0aaa65f5' 
DEBU[0000] using github ref: refs/heads/fix-dusk-tests  
DEBU[0000] Found revision: 85993cc11d108fb8864c151dd805d5fc0aaa65f5 
DEBU[0000] expression 'PHPUnit ${{ matrix.php }}' rewritten to 'format('PHPUnit {0}', matrix.php)' 
DEBU[0000] evaluating expression 'format('PHPUnit {0}', matrix.php)' 
DEBU[0000] expression 'format('PHPUnit {0}', matrix.php)' evaluated to '%!t(string=PHPUnit 8.3)' 
DEBU[0000] Detected CPUs: 2                             
[Unit Testing/PHPUnit 8.3] [DEBUG] evaluating expression 'success()'
[Unit Testing/PHPUnit 8.3] [DEBUG] expression 'success()' evaluated to 'true'
[Unit Testing/PHPUnit 8.3] ๐Ÿš€  Start image=catthehacker/ubuntu:act-latest
[Unit Testing/PHPUnit 8.3]   ๐Ÿณ  docker pull image=mysql/mysql-server:8.0 platform= username= forcePull=true
[Unit Testing/PHPUnit 8.3] [DEBUG]   ๐Ÿณ  docker pull mysql/mysql-server:8.0
[Unit Testing/PHPUnit 8.3] [DEBUG] pulling image 'docker.io/mysql/mysql-server:8.0' ()
DEBU[0000] Saving notices etag=a8049100-3951-46e4-8cb7-45b8dfc2428f 
DEBU[0000] No new notices                               
[Unit Testing/PHPUnit 8.3] [DEBUG] Pulling from mysql/mysql-server :: 8.0
[Unit Testing/PHPUnit 8.3] [DEBUG] Digest: sha256:d6c8301b7834c5b9c2b733b10b7e630f441af7bc917c74dba379f24eeeb6a313 :: 
[Unit Testing/PHPUnit 8.3] [DEBUG] Status: Image is up to date for mysql/mysql-server:8.0 :: 
[Unit Testing/PHPUnit 8.3]   ๐Ÿณ  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[Unit Testing/PHPUnit 8.3] [DEBUG]   ๐Ÿณ  docker pull catthehacker/ubuntu:act-latest
[Unit Testing/PHPUnit 8.3] [DEBUG] pulling image 'docker.io/catthehacker/ubuntu:act-latest' ()
[Unit Testing/PHPUnit 8.3] [DEBUG] Pulling from catthehacker/ubuntu :: act-latest
[Unit Testing/PHPUnit 8.3] [DEBUG] Digest: sha256:89367f3c5437699c6b43fa941041725bcc77682a46f2bbe6557541e384d9cedb :: 
[Unit Testing/PHPUnit 8.3] [DEBUG] Status: Image is up to date for catthehacker/ubuntu:act-latest :: 
[Unit Testing/PHPUnit 8.3] Cleaning up services for job PHPUnit 8.3
[Unit Testing/PHPUnit 8.3] [DEBUG] Removed container: f183db3171f3542b68c3694ac19151b3101983e1c54851a21506bce6fa82a6a5
[Unit Testing/PHPUnit 8.3] Cleaning up network for job PHPUnit 8.3, and network name is: act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network
[Unit Testing/PHPUnit 8.3] [DEBUG] [{xisuma_default 0172d65b1aea017762913b9cff6734cc15f1253dfcd4eaaf205225ef5fee8e2a 2023-06-08 08:56:46.645346577 +0000 UTC local bridge false {default map[] [{172.19.0.0/16  172.19.0.1 map[]}]} false true false {} false map[] map[] map[com.docker.compose.network:default com.docker.compose.project:xisuma com.docker.compose.version:1.29.2] [] map[]} {opensearch_opensearch-net 334a21d6dc018bf03ddf5f2aadf9ce4736a2c85ccc0a4b3385f8017776b45219 2023-09-01 14:05:47.223582541 +0000 UTC local bridge false {default map[] [{172.23.0.0/16  172.23.0.1 map[]}]} false true false {} false map[] map[] map[com.docker.compose.network:opensearch-net com.docker.compose.project:opensearch com.docker.compose.version:1.29.2] [] map[]} {bridge bec5578d4f6eb59d6de71c7ed443e763437aa65cd28dfb96775bee2f9dc95f4c 2024-12-17 13:49:58.482742984 +0000 UTC local bridge false {default map[] [{172.17.0.0/16  172.17.0.1 map[]}]} false false false {} false map[] map[com.docker.network.bridge.default_bridge:true com.docker.network.bridge.enable_icc:true com.docker.network.bridge.enable_ip_masquerade:true com.docker.network.bridge.host_binding_ipv4:0.0.0.0 com.docker.network.bridge.name:docker0 com.docker.network.driver.mtu:1500] map[] [] map[]} {lbd2_default e1b7cfa720c044cc12220fb92ef48fc5276a2a9dec2a8616a1126a0f3d159102 2024-11-24 11:25:56.344720179 +0000 UTC local bridge false {default map[] [{172.20.0.0/16  172.20.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:default com.docker.compose.project:lbd2 com.docker.compose.version:2.30.3] [] map[]} {adelaide_sail b02dbf28107fc98e49a19655df86f8eeb4ac31f20cc9471ea977b27e9902ef14 2024-08-17 12:27:01.100328449 +0000 UTC local bridge false {default map[] [{172.26.0.0/16  172.26.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:sail com.docker.compose.project:adelaide com.docker.compose.version:2.27.0] [] map[]} {act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network 799262c697d9cfe4349628573cfc659b1227f4ccc1ba1d7c2d8c89b719bb5e55 2024-12-18 00:19:30.193433782 +0000 UTC local bridge false {default map[] [{172.22.0.0/16  172.22.0.1 map[]}]} false false false {} false map[] map[] map[] [] map[]} {wikiroo_sail 0868c6ce9f5524184ecb6a3a49ecc810c3186fd3fa47c60e7fe826685eafca14 2023-10-02 13:11:17.05071577 +0000 UTC local bridge false {default map[] [{172.21.0.0/16  172.21.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:sail com.docker.compose.project:wikiroo com.docker.compose.version:2.15.1] [] map[]} {none 4c643f25c77ca5f99ee42021cb6d8a3ebae4e16060db770d02d0b43b33a3e6fc 2021-12-16 07:49:28.442288984 +0000 UTC local null false {default map[] []} false false false {} false map[] map[] map[] [] map[]} {maps_sail 527ff2a741737a657337dddf5d482158fba41c0f17368d93b87dfe1a0a028f71 2024-12-15 05:40:19.080556578 +0000 UTC local bridge false {default map[] [{172.18.0.0/16  172.18.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:sail com.docker.compose.project:maps com.docker.compose.version:2.30.3] [] map[]} {host 8be23970243f78943b66cd598aece5847e5f6844b41115f8e61325750dc00ee4 2021-12-16 07:49:28.671459166 +0000 UTC local host false {default map[] []} false false false {} false map[] map[] map[] [] map[]}]
[Unit Testing/PHPUnit 8.3] [DEBUG] [{host 8be23970243f78943b66cd598aece5847e5f6844b41115f8e61325750dc00ee4 2021-12-16 07:49:28.671459166 +0000 UTC local host false {default map[] []} false false false {} false map[] map[] map[] [] map[]} {adelaide_sail b02dbf28107fc98e49a19655df86f8eeb4ac31f20cc9471ea977b27e9902ef14 2024-08-17 12:27:01.100328449 +0000 UTC local bridge false {default map[] [{172.26.0.0/16  172.26.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:sail com.docker.compose.project:adelaide com.docker.compose.version:2.27.0] [] map[]} {wikiroo_sail 0868c6ce9f5524184ecb6a3a49ecc810c3186fd3fa47c60e7fe826685eafca14 2023-10-02 13:11:17.05071577 +0000 UTC local bridge false {default map[] [{172.21.0.0/16  172.21.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:sail com.docker.compose.project:wikiroo com.docker.compose.version:2.15.1] [] map[]} {none 4c643f25c77ca5f99ee42021cb6d8a3ebae4e16060db770d02d0b43b33a3e6fc 2021-12-16 07:49:28.442288984 +0000 UTC local null false {default map[] []} false false false {} false map[] map[] map[] [] map[]} {maps_sail 527ff2a741737a657337dddf5d482158fba41c0f17368d93b87dfe1a0a028f71 2024-12-15 05:40:19.080556578 +0000 UTC local bridge false {default map[] [{172.18.0.0/16  172.18.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:sail com.docker.compose.project:maps com.docker.compose.version:2.30.3] [] map[]} {lbd2_default e1b7cfa720c044cc12220fb92ef48fc5276a2a9dec2a8616a1126a0f3d159102 2024-11-24 11:25:56.344720179 +0000 UTC local bridge false {default map[] [{172.20.0.0/16  172.20.0.1 map[]}]} false false false {} false map[] map[] map[com.docker.compose.network:default com.docker.compose.project:lbd2 com.docker.compose.version:2.30.3] [] map[]} {xisuma_default 0172d65b1aea017762913b9cff6734cc15f1253dfcd4eaaf205225ef5fee8e2a 2023-06-08 08:56:46.645346577 +0000 UTC local bridge false {default map[] [{172.19.0.0/16  172.19.0.1 map[]}]} false true false {} false map[] map[] map[com.docker.compose.network:default com.docker.compose.project:xisuma com.docker.compose.version:1.29.2] [] map[]} {opensearch_opensearch-net 334a21d6dc018bf03ddf5f2aadf9ce4736a2c85ccc0a4b3385f8017776b45219 2023-09-01 14:05:47.223582541 +0000 UTC local bridge false {default map[] [{172.23.0.0/16  172.23.0.1 map[]}]} false true false {} false map[] map[] map[com.docker.compose.network:opensearch-net com.docker.compose.project:opensearch com.docker.compose.version:1.29.2] [] map[]} {bridge bec5578d4f6eb59d6de71c7ed443e763437aa65cd28dfb96775bee2f9dc95f4c 2024-12-17 13:49:58.482742984 +0000 UTC local bridge false {default map[] [{172.17.0.0/16  172.17.0.1 map[]}]} false false false {} false map[] map[com.docker.network.bridge.default_bridge:true com.docker.network.bridge.enable_icc:true com.docker.network.bridge.enable_ip_masquerade:true com.docker.network.bridge.host_binding_ipv4:0.0.0.0 com.docker.network.bridge.name:docker0 com.docker.network.driver.mtu:1500] map[] [] map[]}]
[Unit Testing/PHPUnit 8.3]   ๐Ÿณ  docker pull image=mysql/mysql-server:8.0 platform= username= forcePull=false
[Unit Testing/PHPUnit 8.3] [DEBUG]   ๐Ÿณ  docker pull mysql/mysql-server:8.0
[Unit Testing/PHPUnit 8.3] [DEBUG] Image exists? true
[Unit Testing/PHPUnit 8.3]   ๐Ÿณ  docker create image=mysql/mysql-server:8.0 platform= entrypoint=[] cmd=[] network="act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network"
[Unit Testing/PHPUnit 8.3] [DEBUG] Common container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[3306/tcp:{}] Tty:true OpenStdin:false StdinOnce:false Env:[MYSQL_DATABASE=database MYSQL_USER=user MYSQL_PASSWORD=password MYSQL_ROOT_PASSWORD=rootpassword] Cmd:[] Healthcheck:<nil> ArgsEscaped:false Image:mysql/mysql-server:8.0 Volumes:map[] WorkingDir:/home/shane/apps/maps Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]}
[Unit Testing/PHPUnit 8.3] [DEBUG] Common container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network PortBindings:map[3306/tcp:[{HostIP: HostPort:3306}]] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:<nil> OomKillDisable:<nil> PidsLimit:<nil> Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>}
[Unit Testing/PHPUnit 8.3] [DEBUG] Custom container.Config from options ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:true AttachStderr:true ExposedPorts:map[] Tty:false OpenStdin:false StdinOnce:false Env:[] Cmd:[] Healthcheck:0xc00014ef00 ArgsEscaped:false Image: Volumes:map[] WorkingDir: Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]}
[Unit Testing/PHPUnit 8.3] [DEBUG] Merged container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:true AttachStderr:true ExposedPorts:map[3306/tcp:{}] Tty:true OpenStdin:false StdinOnce:false Env:[MYSQL_DATABASE=database MYSQL_USER=user MYSQL_PASSWORD=password MYSQL_ROOT_PASSWORD=rootpassword] Cmd:[] Healthcheck:0xc00014ef00 ArgsEscaped:false Image:mysql/mysql-server:8.0 Volumes:map[] WorkingDir:/home/shane/apps/maps Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]}
[Unit Testing/PHPUnit 8.3] [DEBUG] Custom container.HostConfig from options ==> &{Binds:[] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network PortBindings:map[] RestartPolicy:{Name:no MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:0xc00024eec0 OomKillDisable:0xc00024edbb PidsLimit:0xc00024ef20 Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>}
[Unit Testing/PHPUnit 8.3] [DEBUG] Merged container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network PortBindings:map[3306/tcp:[{HostIP: HostPort:3306}]] RestartPolicy:{Name:no MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:0xc00024eec0 OomKillDisable:0xc00024edbb PidsLimit:0xc00024ef20 Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>}
[Unit Testing/PHPUnit 8.3] [DEBUG] input.NetworkAliases ==> [mysql_testing]
[Unit Testing/PHPUnit 8.3] [DEBUG] Created container name=act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94cccc-4a390dc26fd6f47ea22b0dc64b8250eea6aca4b5ac49b55a69b0c7d9ecc886ba id=190c4fd9158bb9117aa7eb5fc78cd224017ff0891ebc9a5ea40d9500fbabc6e6 from image mysql/mysql-server:8.0 (platform: )
[Unit Testing/PHPUnit 8.3] [DEBUG] ENV ==> [MYSQL_DATABASE=database MYSQL_USER=user MYSQL_PASSWORD=password MYSQL_ROOT_PASSWORD=rootpassword]
[Unit Testing/PHPUnit 8.3]   ๐Ÿณ  docker run image=mysql/mysql-server:8.0 platform= entrypoint=[] cmd=[] network="act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94ccccd0bdd2dffb4424f0b440c3eb854d02-testing-network"
[Unit Testing/PHPUnit 8.3] [DEBUG] Starting container: 190c4fd9158bb9117aa7eb5fc78cd224017ff0891ebc9a5ea40d9500fbabc6e6
Error: failed to start container: Error response from daemon: driver failed programming external connectivity on endpoint act-Unit-Testing-PHPUnit-8-3-b5a932e6f0405a4c4e099e52c11b94cccc-4a390dc26fd6f47ea22b0dc64b8250eea6aca4b5ac49b55a69b0c7d9ecc886ba (6ecb2281deb68ad5e7fc3334cfeea4ace52da0cbfa35eee3d6184870f8704bde): Bind for 0.0.0.0:3306 failed: port is already allocated

Additional information

No response

Hi,

Don't you have mysql already running on port 3306 on your system ?

If yes, this is not a bug. You just cannot have your system running a mysql instance on port 3306 and a container with a port bound to the same port number.

Hi,

Don't you have mysql already running on port 3306 on your system ?

If yes, this is not a bug. You just cannot have your system running a mysql instance on port 3306 and a container with a port bound to the same port number.

Is it not possible to run act in non host network mode?

Is it not possible to run act in non host network mode?

Not for the workflow the original poster has presented. This would require an advanced DinD setup for the localhost part that is not supported.

name: Unit Testing

on:
  workflow_dispatch:
  push:

concurrency:
  group: cc-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:

  testing:
    name: PHPUnit ${{ matrix.php }}
    runs-on: ubuntu-latest
    timeout-minutes: 12

    strategy:
      fail-fast: true
      matrix:
        php: [ 8.3 ]
    
    services:
      mysql_testing:
        image: mysql/mysql-server:8.0
        env:
          MYSQL_DATABASE: database
          MYSQL_USER: user
          MYSQL_PASSWORD: password
          MYSQL_ROOT_PASSWORD: rootpassword
        # Removed exposing port to host
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
    
    # This field is required for the changed workflow to work online
    container: catthehacker/ubuntu:act-latest # use any container image with mysql cli / create your own
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 1

     # Now avoid localhost and use the service name
      - name: Verify MySQL connection
        run: |
          mysql --version
          sudo apt-get install -y mysql-client
          mysql --host mysql_testing --port 3306 -uuser -ppassword -e "SHOW DATABASES"

The following part might break act as well and download the sources from the github instead of the local version

        with:
          fetch-depth: 1