[GH-ISSUE #1662] Is it possible to run jobs by specifying container? #824

Closed
opened 2026-03-01 21:46:42 +03:00 by kerem · 2 comments
Owner

Originally created by @aeiouaoeiuv on GitHub (Mar 3, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/1662

Act version

0.2.43

Feature description

I created a container by docker compose. And this container is always running. Also with some environments set and volumes set in compose.yaml.
How to use act with some arguments to run jobs in the container I created, instead of created by act itself?

Originally created by @aeiouaoeiuv on GitHub (Mar 3, 2023). Original GitHub issue: https://github.com/nektos/act/issues/1662 ### Act version 0.2.43 ### Feature description I created a container by docker compose. And this container is always running. Also with some environments set and volumes set in compose.yaml. How to use act with some arguments to run jobs in the container I created, instead of created by act itself?
kerem 2026-03-01 21:46:42 +03:00
Author
Owner

@alex-savchuk commented on GitHub (Mar 7, 2023):

Maybe container option helps with that:

name: container-hostname
on: push

defaults:
  run:
    shell: bash

jobs:
  with-hostname:
    runs-on: ubuntu-latest
    container:
      image: node:16-buster-slim
      options: "--hostname my.host.local --user 100:101"
    steps:
      - run: |
          echo "UID: $(id -u)"
          echo "GID: $(id -g)"
          echo "HOST: $(uname -n)"
          [[ "$(id -u)" == "100" ]] && [[ "$(id -g)" == "101" ]] && [[ "$(uname -n)" == "my.host.local" ]]

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainer

<!-- gh-comment-id:1458445182 --> @alex-savchuk commented on GitHub (Mar 7, 2023): Maybe container option helps with that: ``` name: container-hostname on: push defaults: run: shell: bash jobs: with-hostname: runs-on: ubuntu-latest container: image: node:16-buster-slim options: "--hostname my.host.local --user 100:101" steps: - run: | echo "UID: $(id -u)" echo "GID: $(id -g)" echo "HOST: $(uname -n)" [[ "$(id -u)" == "100" ]] && [[ "$(id -g)" == "101" ]] && [[ "$(uname -n)" == "my.host.local" ]] ``` https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainer
Author
Owner

@aeiouaoeiuv commented on GitHub (Mar 8, 2023):

Maybe container option helps with that:

name: container-hostname
on: push

defaults:
  run:
    shell: bash

jobs:
  with-hostname:
    runs-on: ubuntu-latest
    container:
      image: node:16-buster-slim
      options: "--hostname my.host.local --user 100:101"
    steps:
      - run: |
          echo "UID: $(id -u)"
          echo "GID: $(id -g)"
          echo "HOST: $(uname -n)"
          [[ "$(id -u)" == "100" ]] && [[ "$(id -g)" == "101" ]] && [[ "$(uname -n)" == "my.host.local" ]]

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainer

This solves part of my needs. But also do the work.
I just need to add all my compose.yaml options to the yml file. And then, act will create a new container with my options and do the jobs.
I thought act could use my existing container without creating a new one.
Thanks @alex-savchuk , closing this.

<!-- gh-comment-id:1459359339 --> @aeiouaoeiuv commented on GitHub (Mar 8, 2023): > Maybe container option helps with that: > > ``` > name: container-hostname > on: push > > defaults: > run: > shell: bash > > jobs: > with-hostname: > runs-on: ubuntu-latest > container: > image: node:16-buster-slim > options: "--hostname my.host.local --user 100:101" > steps: > - run: | > echo "UID: $(id -u)" > echo "GID: $(id -g)" > echo "HOST: $(uname -n)" > [[ "$(id -u)" == "100" ]] && [[ "$(id -g)" == "101" ]] && [[ "$(uname -n)" == "my.host.local" ]] > ``` > > https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainer This solves part of my needs. But also do the work. I just need to add all my `compose.yaml` options to the yml file. And then, `act` will create a new container with my options and do the jobs. I thought `act` could use my existing container without creating a new one. Thanks @alex-savchuk , closing this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#824
No description provided.