# Running Jobs in a Container

We can run jobs in a container in the following way -

## 1. Running a job within a container

```yaml
name: My CI
on:
    push:
        branches: [main]
jobs:
    container-job:
        runs-on: ubuntu-latest
        container:
            image: crazyuploader/minimal_ubuntu:latest
            env:
                IS_PRODUCTION: true
```

If no other options are specified, we can simply write -

```yaml
jobs:
    container-job:
        runs-on: ubuntu-latest
        container: crazyuploader/minimal_ubuntu:latest
```

## 2. Defining credentials for a container registry

```yaml
container:
    image: crazyuploader/private_container
    credentials:
        username: ${{ secrets.USERNAME }}
        password: ${{ secrets.PASSWORD }}
```

***Reference:*** [***GitHub Actions - GitHub Docs***](https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.devjugal.com/github/actions/running-jobs-in-a-container.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
