docker-compose: command not found

Hi all,

Just started with Github Actions and I’ve got some issues getting it to work.

The workflow that I created:

name: Pull request

on: pull_request

jobs:
test-unit:
runs-on: ubuntu-latest
steps:
-uses: actions/checkout@develop
-name: Docker compose
run: docker-compose up -d

I use https://github.com/nektos/act to verify the changes locally on my MackBook Pro.

So, I run act pull_request and the result that I get:

[Pull request/test-unit] ⭐ Run actions/checkout@develop
[Pull request/test-unit] ✅ Success - actions/checkout@develop
[Pull request/test-unit] ⭐ Run Docker compose
[Pull request/test-unit] 🐳 docker pull ubuntu:18.04
[Pull request/test-unit] 🐳 docker run image=ubuntu:18.04 entrypoint=["bash" "--noprofile" "--norc" "-eo" "pipefail" "/github/home/.temp-script-299945376"] cmd=[]
| /github/home/.temp-script-299945376: line 2: docker-compose: command not found
[Pull request/test-unit] ❌ Failure - Docker compose
Error: exit with `FAILURE`: 127

So what do I do wrong?
If I check this issue: https://github.community/t5/GitHub-Actions/How-to-use-docker-compose-with-GitHub-Actions/td-p/37824 than it should work like that right?

1 Like

Hi @verschoof ,

I can reproduce with act installed on my local machine. 

Firstly, the ‘develop’ branch doesn’t exist for action checkout, looks ‘act pull_request’ doesn’t pointed this out. You can use ‘actions/checkout@v2’ instead.

Secondly, command ‘docker-compose’ is supported by default, but it requires ‘docker-compose.yml’ as a configuration file,  please confirm you have created the ‘docker-compose.yml’ file. 

Hence, the workflow should be like below, please refer to the link for more details.

jobs:
  test-unit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Docker compose
        run: docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d

Hope it helps!

1 Like

Hi @weide-zhou 

Thanks for checking!

I changed the script .github/workflows/pull-request.yml to

name: Pull request

on: pull_request

jobs:
  test-unit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Docker compose
        run: docker-compose -f docker-compose.yml up -d
      - name: Check running containers
        run: docker ps -a
      - name: Docker compose
        run: docker-compose up -d

I do have a docker-compose.yml in the root dir of the project.

When running act pull_request I still got an error:

[Pull request/test-unit] ⭐ Run actions/checkout@v2
[Pull request/test-unit] ✅ Success - actions/checkout@v2
[Pull request/test-unit] ⭐ Run Docker compose
[Pull request/test-unit] 🐳 docker pull ubuntu:18.04
[Pull request/test-unit] 🐳 docker run image=ubuntu:18.04 entrypoint=["bash" "--noprofile" "--norc" "-eo" "pipefail" "/github/home/.temp-script-099686188"] cmd=[]
| /github/home/.temp-script-099686188: line 2: docker-compose: command not found
[Pull request/test-unit] ❌ Failure - Docker compose
Error: exit with `FAILURE`: 127
1 Like

Hi @verschoof ,

Did you install/enable docker on your MacBook Pro? As you use ‘act’ to run the workflow locally, if command still not found, i assume it should be related to ‘act’ itself but not your yaml file.  It’s recommended to raise an ticket in act issue list here.

Thanks.

1 Like

I also work with docker locally and that works fine.

I pushed the files to github and its running there too.

I will create an issue on act.

Thanks for the help @weide-zhou 

1 Like

Default Act runners do not contain all the tools that GitHub Actions offers by default in their runners. If you need an environment that works just like the corresponding GitHub runner then consider using an image provided by nektos/act-environments

nektos/act-environments-ubuntu:18.04 - built from the Packer file GitHub uses in actions/virtual-environments (WARNING - this image is >18GB).