How to use docker-compose with GitHub Actions? #27185
-
Hi! I am trying to use GitHub actions to automate my test pipeline, but cannot seem to get the containers to run in order to test them. I am running a django webapp in one container and postgres in another and tying the two with docker-compose. My docker-compose.yml file is
and my GitHub actions file is:
Note that I added the 60s wait time, because I thought the test suite was running before the container could stand up but it didn’t seem to help. The output of the “docker ps” call is below. Note that the web service is not running:
and the output of the test step is:
This docker-compose file works great locally but something seems to be amiss when running on GitHub actions. Really appreciate any advice you have! |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
Glad to hear you in GitHub Community. Please try to run docker ps -a It will list all containers including exited ones. Based on your docker-compose.yml, it seems that backend container has exited immediately after building the image. Use jakejarvis/wait-action@master action could not keep container running. You can try to add next command at the end of your docker file. CMD tail -f /dev/null You can refer to this blog. http://bigdatums.net/2017/11/07/how-to-keep-docker-containers-running/ |
Beta Was this translation helpful? Give feedback.
-
Hi Yanjingzhu, Thanks for your help! It turns out the issue was actually with my volume command in the docker-compose file, which was looking for a volume that doesn’t exist on the GitHub Actions VM. To debug, I used the command:
Which pointed out that gunicorn was unable to find my django app:
I think that the volume I was calling was actually overwriting all my code, since there was nothing in the volume in the actions VM. I didn’t test this thouroughly, but I did get it to work by splitting my docker-compose file into three files: A base configuration, a local configuration, and a ci configuration Base config
Local dev config:
CI config
I then updated my github actions yml file:
The main change to the GitHub actions file is changing the docker-compose command to use the docker-compose.ci.yml file. Hope this is helpful to future users! Looks like docker-compose works as expected, I just forgot that my local volume would not be available on the server. |
Beta Was this translation helpful? Give feedback.
-
Man, You saved my life! The docker volumes thing gaves me headaches… |
Beta Was this translation helpful? Give feedback.
-
Hi, I look at your issue and solution, I’m sure my case is very similar but I’m not working out a solution. The error is almost identical, yet… I’m using Here is
Just in case it helps, my
I’m trying to run my
My current
Then, when I run
I understand that volume containing the app is not well setup, but how to change that? In your example |
Beta Was this translation helpful? Give feedback.
-
Hi, I’ve user curl command to test spring-boot docker deployment like below:
|
Beta Was this translation helpful? Give feedback.
-
I have a question is using docker-compose here the best practice or would it be a considerable improvement to use: |
Beta Was this translation helpful? Give feedback.
Glad to hear you in GitHub Community.
Please try to run docker ps -a It will list all containers including exited ones. Based on your docker-compose.yml, it seems that backend container has exited immediately after building the image.
Use jakejarvis/wait-action@master action could not keep container running.
You can try to add next command at the end of your docker file.
CMD tail -f /dev/null
You can refer to this blog.
http://bigdatums.net/2017/11/07/how-to-keep-docker-containers-running/