Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update section-running-jobs-in-a-container.md #37028

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions data/reusables/actions/jobs/section-running-jobs-in-a-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ If you do not set a `container`, all steps will run directly on the host specifi
> [!NOTE]
> The default shell for `run` steps inside a container is `sh` instead of `bash`. This can be overridden with [`jobs.<job_id>.defaults.run`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun) or [`jobs.<job_id>.steps[*].shell`](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell).

> [!NOTE]
> If you supply your own container image, the `WORKDIR` statement may not be detected and you will need to (re)specify it yourself with the [`jobs.<job_id>.defaults.run.working-directory](/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iddefaultsrunworking-directory) option.

### Example: Running a job within a container

```yaml copy
Expand Down Expand Up @@ -37,3 +40,31 @@ jobs:
runs-on: ubuntu-latest
container: node:18
```
### Example: Running a job within a custom container with a working directory set
```yaml copy
name: CI
on:
push:
branches: [ main ]
jobs:
container-test-job:
runs-on: ubuntu-latest
defaults:
run:
working-directory: `/home/app/webapp`
container:
image: myimage
credentials:
username: MYUSERNAME
password: MYPASSWORD
env:
NODE_ENV: development
ports:
- 80
volumes:
- my_docker_volume:/volume_mount
options: --cpus 1
steps:
- name: Check for dockerenv file
run: (ls .dockerenv && echo Found dockerenv) || (echo No dockerenv)
```
Loading