env)
    

When you only specify a container image, you can omit the ` image ` keyword.

    
    
    jobs:
      container-test-job:
        runs-on: ubuntu-latest
        container: node:18
    

##  Defining the container image

Use ` jobs.<job_id>.container.image ` to define the Docker image to use as the
container to run the action. The value can be the Docker Hub image name or a
registry name.

##  Defining credentials for a container registry

If the image's container registry requires authentication to pull the image,
you can use ` jobs.<job_id>.container.credentials ` to set a ` map ` of the `
username ` and ` password ` . The credentials are the same values that you
would provide to the [ ` docker login `
](https://docs.docker.com/engine/reference/commandline/login/) command.

####  Example: Defining credentials for a container registry

    
    
    container:
      image: ghcr.io/owner/image
      credentials:
         username: ${{ github.actor }}
         password: ${{ secrets.github_token }}
    

##  Using environment variables with a container

Use ` jobs.<job_id>.container.env ` to set a ` map ` of environment variables
in the container.

##  Exposing network ports on a container

Use ` jobs.<job_id>.container.ports ` to set an ` array ` of ports to expose
on the container.

##  Mounting volumes in a container

Use ` jobs.<job_id>.container.volumes ` to set an ` array ` of volumes for the
container to use. You can use volumes to share data between services or other
steps in a job. You can specify named Docker volumes, anonymous Docker
volumes, or bind mounts on the host.

To specify a volume, you specify the source and destination path:

` <source>:<destinationPath> ` .

The ` <source> ` is a volume name or an absolute path on the host machine, and
` <destinationPath> ` is an absolute path in the container.

####  Example: Mounting volumes in a container

    
    
    volumes:
      - my_docker_volume:/volume_mount
      - /data/my_data
      - /source/directory:/destination/directory
    

##  Setting container resource options

Use ` jobs.<job_id>.container.options ` to configure additional Docker
container resource options. For a list of options, see " [ ` docker create `
options
](https://docs.docker.com/engine/reference/commandline/create/#options) ."

**Warning:** The ` --network ` and ` --entrypoint ` options are not supported.

##  Help and support

###  Did this doc help you?

Yes  No

[ Privacy policy ](/en/site-policy/privacy-policies/github-privacy-statement)

###  Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit
a pull request.

[ Make a contribution
](https://github.com/github/docs/blob/main/content/actions/using-jobs/running-
jobs-in-a-container.md)

[ Learn how to contribute ](/contributing)

###  Still need help?

[ Ask the GitHub community ](https://github.com/orgs/community/discussions)

[ Contact support ](https://support.github.com)

##  Legal

  * ©  2024  GitHub, Inc. 
  * [ Terms ](/en/site-policy/github-terms/github-terms-of-service)
  * [ Privacy ](/en/site-policy/privacy-policies/github-privacy-statement)
  * [ Status ](https://www.githubstatus.com/)
  * [ Pricing ](https://github.com/pricing)
  * [ Expert services ](https://services.github.com)
  * [ Blog ](https://github.blog)