GitHub workflow action with docker compose
Asked Answered
C

0

2

I'm trying to setup CI with GitHub Actions. My project is using docker & docker-compose (Laradock actually, but that does not matter). It is the first time I'm setting up a workflow/ action with GitHub. I'm used to gitlab-ci... however

In one step I'm running the docker containers:

  • docker-compose up -d nginx mariadb
Creating laradock_mariadb_1 ... 
Creating laradock_docker-in-docker_1 ... 

Creating laradock_mariadb_1          ... done

Creating laradock_docker-in-docker_1 ... done
Creating laradock_workspace_1        ... 

Creating laradock_workspace_1        ... done
Creating laradock_php-fpm_1          ... 

Creating laradock_php-fpm_1          ... done
Creating laradock_nginx_1            ... 

Creating laradock_nginx_1            ... done

And in the next step I want to use the containers:

  • docker-compose exec workspace composer install

This fails with the message: No container found for workspace_1

I am assuming I need to do something like creating an artifact for the first step and use it in the second step. At least that's something you'd do in GitLab CI.

I have not found any examples or solutions on the internet. I guess because GitHub's Actions is still a very new feature. So hopefully this thread will help other beginners as well.

EDIT

Conservatism answered 12/1, 2020 at 20:52 Comment(6)
Can you post your actual docker-compose.yml and workflow yml file. Github action steps do not run in separate environmentsUnderarm
@Underarm I attached them to the post.Conservatism
See if this link helps: forums.docker.com/t/… It seems the problem is that you needed to do docker-compose up -d workspace before running this stepUnderarm
@Underarm Thank you but it is definetely up, as you can see from the logs of the previous step. This works perfectly on my local machine.Conservatism
I just tested the ability to run a command in a Docker-Compose container started by a GitHub Actions step earlier - and it works as this build log shows. I have a slightly different Docker-Compose setup (here's the full project), so I guess it has something to do with specific configuration or directory structure of yours? An example project on GitHub solely for this would help...Monodrama
Just be sure to exec into the containers with the -T parameter like this: docker-compose exec -T workspace composer install. With this parameter you can switch off the default pseudo-tty allocation by Compose. Otherwise you'll run into errors like the input device is not a TTY. Also you could use a docker ps -a to show all running containers, so you should see if there's really no workspace_1... (example build here)Monodrama

© 2022 - 2025 — McMap. All rights reserved.