# "runs-on" vs "container"

**URL:** <https://forum.gitea.com/t/runs-on-vs-container/10383>\
**Category:** Actions\
**Created:** [January 8, 2025, 12:26am UTC](https://forum.gitea.com/t/runs-on-vs-container/10383 "2025-01-08T00:26:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghnp5](https://avatars.discourse-cdn.com/v4/letter/g/f9ae1b/32.png) [@ghnp5](https://forum.gitea.com/u/ghnp5)\
**Post date:** [January 8, 2025, 12:26am UTC](https://forum.gitea.com/t/runs-on-vs-container/10383/1 "2025-01-08T00:26:22Z")

</div>

Hey!  
I tried to find documentation on this, but I couldn’t find anything.

When we have:

```auto
jobs:
  job_name:
    name: Job Name
    runs-on: ubuntu-latest
    container:
      image: docker:latest

```

Does `container` override `runs-on`?  
Or, does the job spin up a container with whatever image is assigned to `ubuntu-latest` (in `config.yaml`), which will then spin up a separate container running `docker:latest`?

Note – in my env, both Gitea and the Actions Runner are running on docker. The Actions Runner spins up containers on the host’s `docker.sock`.

–

For cases where I want to specify a volume to mount…

Is this something valid to do? Omitting `container.image`, and specifying the image alias in `runs-on`:

```auto
jobs:
  job_name:
    name: Job Name
    runs-on: docker-latest
    container:
      volumes:
        - /path1/:/path1/

```

Or, alternatively, omitting `runs-on`:

```auto
jobs:
  job_name:
    name: Job Name
    container:
      image: docker:latest
      volumes:
        - /path1/:/path1/

```

–

In other words, what I’m looking for is to prevent doing this:

**Actions Runner** (running `gitea/act_runner:latest`)  
→ **Spins up** `gitea/runner-images:ubuntu-latest` (based on `runs-on`)  
→ **Spins up** `docker:latest` (based on `container`)

And instead, do this:

**Actions Runner** (running `gitea/act_runner:latest`)  
→ **Spins up** `docker:latest` (based on `container`)

(for cases where I want to specify a `volume` to be mounted, for that specific job, and hence the reason to use the `container` node)

Thanks!

---

<div class="post-metadata">

**Author:** ![JagWireZ](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/jagwirez/32/6554_2.png) [@JagWireZ](https://forum.gitea.com/u/JagWireZ)\
**Post date:** [January 8, 2025, 7:07pm UTC](https://forum.gitea.com/t/runs-on-vs-container/10383/2 "2025-01-08T19:07:20Z")

</div>

Ditto. I’d like to pass a file, or a variable, down from the action runner to the jobs, but I’m confused on the difference of runs-on vs container.

---

<div class="post-metadata">

**Author:** ![TechWiz](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@TechWiz](https://forum.gitea.com/u/TechWiz)\
**Post date:** [January 11, 2025, 1:09am UTC](https://forum.gitea.com/t/runs-on-vs-container/10383/3 "2025-01-11T01:09:21Z")

</div>

Here are a couple observations. I can speak to the number of running containers.

I use `runs-on:` to select the runner. I use `container:` when I need a job-specific image.

When I specify with both `runs-on:` and `container:`, I see:

```sh
$ docker container ls -a
CONTAINER ID IMAGE
------------ gitea.myinstance.com/public/syncthing-android-builder:latest
------------ gitea/act_runner:latest

```

When I specify only `runs-on:`, I see:

```sh
$ docker container ls -a
CONTAINER ID IMAGE
------------ gitea/runner-images:ubuntu-latest
------------ gitea/act_runner:latest

```

It appears `container:` overrides the image used to run the job container which results in only two images running.

Here are snippets from the workflow yaml files:

- With both `runs-on:` and `container:` specified:

```yaml
jobs:
  build:
    name: Debug Build
    runs-on: ubuntu-latest
    container: gitea.myinstance.com/public/syncthing-android-builder:latest

```

- With only `runs-on:` specified:

```yaml
jobs:
  Explore-Gitea-Actions:
    runs-on: [ubuntu-latest]
    steps:
      ...
      - name: Long Sleep
        run: |
          sleep 10000000

```

**Note:** the `sleep 10000000` has been useful when I need to keep the job container running to debug build issues inside the running job container.

---

<div class="post-metadata">

**Author:** ![ghnp5](https://avatars.discourse-cdn.com/v4/letter/g/f9ae1b/32.png) [@ghnp5](https://forum.gitea.com/u/ghnp5)\
**Post date:** [January 11, 2025, 1:22am UTC](https://forum.gitea.com/t/runs-on-vs-container/10383/4 "2025-01-11T01:22:09Z")

</div>

Oh, many thanks for this!

That was very useful and informative.

That’s very good, if that’s how it works, then!! 🙂
