-
I have just started experimenting with the CI/CD functionality of GitHub Actions, and I fail to understand the “runs-on” and “container” options.
Please excuse me if I am getting something totally the wrong way… I started experimenting with CI/CD only a couple of days ago. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
> Why both “runs-on” and “container” are required when I want to run a container, and what exactly does this mean? Let’s say for example that I have “runs-on: ubuntu-latest” and “container: centos-latest”. Does this mean that my requested centos-latest image will run on an ubuntu-latest virtual machine? Why do I even have to specify the host operating system (ubuntu-latest) if I plan to use a container and do everything I want to do there? Yes, you’re exactly right - that’s what that means. You need to specify that because the underlying virtual machine dictates the type of containers that you can run. You need an underlying Windows virtual machine (ie, Since we don’t know what type of container you’re trying to run until we download it, we can’t let you skip specifying a virtual machine type. (We need to provision a virtual machine just to do that download.) > What if someone wants to create a build matrix with different containers? To my understanding this is not possible at the moments because the build matrix somehow works only with the “runs-on” option. That’s possible - there’s nothing special about the runs-on key in a matrix. A matrix is really only variable substitution. To use a matrix of different containers, you can:
|
Beta Was this translation helpful? Give feedback.
-
Excellent explanation! Thank you so much my friend! |
Beta Was this translation helpful? Give feedback.
-
Searching for exactly this explination - many thanks for explaining so cleanly |
Beta Was this translation helpful? Give feedback.
-
Before jumping to the WHY question, let's first dig into the WHAT and the essence of these two. With [runs-on], we can specify the host environment of the workflow. We can specify the job environment with [container]. Back to the original question, we are enhancing task isolation and efficiently managing different environments with a simple configuration file.
You are getting this error because the kernels of MacOS and CentOS are different. The docker container uses the kernel of the host machine and should belong to the same Operating System.
If you will use only "runs-on" then you will have only 1 Operating System i.e. Host OS, but if you use it along with "container" you will get different environment ( Host OS, Container OS) to work with and you can simply create individual jobs in your workflow file, each specifying a different container. |
Beta Was this translation helpful? Give feedback.
> Why both “runs-on” and “container” are required when I want to run a container, and what exactly does this mean? Let’s say for example that I have “runs-on: ubuntu-latest” and “container: centos-latest”. Does this mean that my requested centos-latest image will run on an ubuntu-latest virtual machine? Why do I even have to specify the host operating system (ubuntu-latest) if I plan to use a container and do everything I want to do there?
Yes, you’re exactly right - that’s what that means.
You need to specify that because the underlying virtual machine dictates the type of containers that you can run. You need an underlying Windows virtual machine (ie,
runs-on: windows-latest
) to use Wi…