ures  ](/en/actions/security-guides/using-githubs-security-features-to-secure-your-use-of-github-actions)
    * [ Automatic token authentication  ](/en/actions/security-guides/automatic-token-authentication)

  * Creating actions 

    * [ About custom actions  ](/en/actions/creating-actions/about-custom-actions)
    * [ Create a Docker container action  ](/en/actions/creating-actions/creating-a-docker-container-action)
    * [ Create a JavaScript action  ](/en/actions/creating-actions/creating-a-javascript-action)
    * [ Create a composite action  ](/en/actions/creating-actions/creating-a-composite-action)
    * [ Metadata syntax  ](/en/actions/creating-actions/metadata-syntax-for-github-actions)
    * [ Dockerfile support  ](/en/actions/creating-actions/dockerfile-support-for-github-actions)
    * [ Set exit codes  ](/en/actions/creating-actions/setting-exit-codes-for-actions)
    * [ Publish in GitHub Marketplace  ](/en/actions/creating-actions/publishing-actions-in-github-marketplace)
    * [ Share from your private repository  ](/en/actions/creating-actions/sharing-actions-and-workflows-from-your-private-repository)
    * [ Share with your organization  ](/en/actions/creating-actions/sharing-actions-and-workflows-with-your-organization)
    * [ Release and maintain actions  ](/en/actions/creating-actions/releasing-and-maintaining-actions)
    * [ CLI setup action  ](/en/actions/creating-actions/developing-a-third-party-cli-action)

  * [ Guides for GitHub Actions  ](/en/actions/guides)

  * [ GitHub Actions ](/en/actions "GitHub Actions") / 
  * [ Using jobs ](/en/actions/using-jobs "Using jobs") / 
  * [ Run jobs in a container ](/en/actions/using-jobs/running-jobs-in-a-container "Run jobs in a container")

#  Running jobs in a container

Use a container to run the steps in a job.

##  In this article

  * Overview 
  * Defining the container image 
  * Defining credentials for a container registry 
  * Using environment variables with a container 
  * Exposing network ports on a container 
  * Mounting volumes in a container 
  * Setting container resource options 

##  Overview

Use ` jobs.<job_id>.container ` to create a container to run any steps in a
job that don't already specify a container. If you have steps that use both
script and container actions, the container actions will run as sibling
containers on the same network with the same volume mounts.

If you do not set a ` container ` , all steps will run directly on the host
specified by ` runs-on ` unless a step refers to an action configured to run
in a container.

**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 ` ](/en/actions/using-workflows/workflow-syntax-
for-github-actions#jobsjob_iddefaultsrun) or [ ` jobs.<job_id>.steps[*].shell
` ](/en/actions/using-workflows/workflow-syntax-for-github-
actions#jobsjob_idstepsshell) .

###  Example: Running a job within a container

YAML

    
    
    name: CI
    on:
      push:
        branches: [ main ]
    jobs:
      container-test-job:
        runs-on: ubuntu-latest
        container:
          image: node:18
          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)
    
    
    
    name: CI
    on:
      push:
        branches: [ main ]
    jobs:
      container-test-job:
        runs-on: ubuntu-latest
        container:
          image: node:18
          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 docker