Github actions: run multiple jobs in the same docker #26545
-
I’m learning to deploy github actions to run multiple jobs with docker, and this is what I have so far: github actions yml file is shown as follow. There are 2 jobs:
I wonder, can I build a docker for the 1st job, and then invoke multiple jobs execute command within the docker built from the 1st job? Thus I don’t have to keep multiple Dockerfile and save some docker building time. It would be better to build my docker locally from Dockerfile so I hope to avoid using runs-for-docker-actions looks relevant but I have trouble finding example deploying action locally (without publishing). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
wentaocn:
I’m not exactly sure what you’re trying to do, do you want to use a container built in one job as the build environment (job container, even?) for later jobs? One thing I can definitely say is that jobs in GitHub hosted runners each get a fresh VM, so if you build a container in one job and want to use it in another you have to push it to a registry, or store the image somewhere else. |
Beta Was this translation helpful? Give feedback.
-
This is certainly something I didn’t know. Thanks, problem solved. |
Beta Was this translation helpful? Give feedback.
I’m not exactly sure what you’re trying to do, do you want to use a container built in one job as the build environment (job container, even?) for later jobs?
One thing I can definitely say is that jobs in GitHub hosted runners each get a fresh VM, so if you build a container in one job and want to use it in another you have to push it to a registry, or store the image somewhere else.