https://github.com/vjik/docker-run
GitHub Action that runs a command in a new Docker container with a simple, declarative syntax.
https://github.com/vjik/docker-run
actions ci container docker
Last synced: 4 months ago
JSON representation
GitHub Action that runs a command in a new Docker container with a simple, declarative syntax.
- Host: GitHub
- URL: https://github.com/vjik/docker-run
- Owner: vjik
- License: bsd-3-clause
- Created: 2026-02-18T08:09:13.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2026-02-18T12:34:16.000Z (4 months ago)
- Last Synced: 2026-02-18T15:47:30.842Z (4 months ago)
- Topics: actions, ci, container, docker
- Language: Shell
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yaml
- License: LICENSE
Awesome Lists containing this project
README
# `vjik/docker-run` GitHub Action
[](https://github.com/vjik/docker-run/releases)
[](./LICENSE)
GitHub Action that runs a command in a new Docker container with a simple, declarative syntax.
**Features:**
- Run commands in any Docker image directly from your workflow
- Mount volumes and pass environment variables with multi-line input support
- Authenticate with private registries (Docker Hub, GHCR, and others)
- Pass additional `docker run` options for full flexibility
> [!IMPORTANT]
> This project is developed and maintained by [Sergei Predvoditelev](https://github.com/vjik).
> Community support helps keep the project actively developed and well maintained.
> You can support the project using the following services:
>
> - [Boosty](https://boosty.to/vjik)
> - [CloudTips](https://pay.cloudtips.ru/p/192ce69b)
>
> Thank you for your support ❤️
## General usage
### Basic
```yaml
- uses: vjik/docker-run@v1
with:
image: ubuntu:24.04
command: echo "Hello from container"
```
### Volume mounts and environment variables
```yaml
- uses: vjik/docker-run@v1
with:
image: python:3.12
volumes: |
${{ github.workspace }}:/work
/tmp/cache:/cache
env: |
CI=true
GREETING=Hello World
workdir: /work
command: |
pip install -r requirements.txt
python -m pytest tests/
```
### Using bash
By default, commands run via `sh -c`. To use bash-specific syntax, invoke `bash -c` explicitly:
```yaml
- uses: vjik/docker-run@v1
with:
image: bash:5
volumes: ${{ github.workspace }}:/work
command: |
bash -c 'arr=(one two three); echo "${arr[@]}" > /work/result.txt'
```
### Private registry
```yaml
- uses: vjik/docker-run@v1
with:
image: ghcr.io/my-org/my-image:latest
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
command: echo "Authenticated"
```
Without `registry`, authentication defaults to Docker Hub:
```yaml
- uses: vjik/docker-run@v1
with:
image: my-org/my-private-image:latest
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
command: echo "Authenticated to Docker Hub"
```
## Inputs
| Input | Required | Description |
|------------|-----------|--------------------------------------------------------------------------------------------|
| `image` | Yes | Docker image to run (e.g. `ubuntu:24.04`, `python:3.12`) |
| `command` | Yes | Shell command to run inside the container |
| `volumes` | No | Volume mounts, one per line (e.g. `/host/path:/container/path`) |
| `env` | No | Environment variables, one per line (e.g. `MY_VAR=some value`) |
| `workdir` | No | Working directory inside the container |
| `options` | No | Additional `docker run` options (e.g. `--network host --cpus 2`) |
| `registry` | No | Docker registry URL for authentication (e.g. `ghcr.io`). Defaults to Docker Hub if omitted |
| `username` | No | Username for Docker registry authentication |
| `password` | No | Password or token for Docker registry authentication |
## Limitations
- Values with spaces in the `options` input are not supported (e.g. `-e MY_VAR="Hello World"`). Use `volumes`, `env` and
`workdir` inputs instead, which handle spaces correctly.
- The command is executed via `sh -c`, so bash-specific syntax is not available unless the container image includes bash
and you invoke it explicitly (e.g. `bash -c "..."`).
## License
The `vjik/docker-run` is free software. It is released under the terms of the BSD License.
Please see [`LICENSE`](./LICENSE) for more information.
## Credits
The package is inspired by [addnab/docker-run-action](https://github.com/addnab/docker-run-action) package.