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
- My full workflow: tests.yml
- docker-compose.yml from Laradock (it's the one my project uses too)
docker-compose.yml
and workflow yml file. Github action steps do not run in separate environments – Underarmdocker-compose up -d workspace
before running this step – Underarmexec
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 likethe input device is not a TTY
. Also you could use adocker ps -a
to show all running containers, so you should see if there's really noworkspace_1
... (example build here) – Monodrama