Skip to main content

A tool to parse rockerc.yaml files and pass on the arguments onto rocker

Project description

rockerc

Continuous Integration Status

Ci Codecov GitHub issues GitHub pull-requests merged GitHub release PyPI - Downloads License Python Pixi Badge

Installation

Recommended Method:

Install pipx (if not already installed):

sudo apt install pipx
pipx ensurepath

Then install rockerc and its dependencies globally with:

pipx install --include-deps rockerc

to develop run

pipx install --include-deps . --force

This will ensure that rockerc and rocker commands are available on your PATH.

Usage

navigate to a directory with a rockerc.yaml file and run:

rockerc

This will search recursively for rockerc.yaml and pass those arguments to rocker

Unified Detached Execution & VS Code Integration

rockerc now always launches (or reuses) the container in detached mode and then opens an interactive shell via docker exec. This avoids stdin/TTY interference and enables a reliable VS Code attach workflow.

Basic run (detached + shell):

rockerc

Attach VS Code as well (exact same container) using the new flag:

rockerc --vsc

For convenience, the rockervsc command is just an alias for:

rockerc --vsc

What Happens Under the Hood

  1. Merge global (~/.rockerc.yaml) and project rockerc.yaml config.
  2. If a dockerfile key exists, build a tagged image and strip the pull extension.
  3. Ensure required rocker flags are injected:
    • --detach
    • --name <container> / --image-name <container>
    • Workspace volume mount: <project>:/workspaces/<container>
  4. Run rocker only if the container does not already exist.
  5. (Optional) Launch VS Code: code --folder-uri vscode-remote://attached-container+<hex>/workspaces/<container>
  6. Open an interactive shell with docker exec -it <container> $SHELL.

Reusing Containers

If a container with the derived name already exists, rockerc reuses it (skips rocker invocation) and simply attaches shell / VS Code (if --vsc).

Force a fresh container (timestamp-rename the old one):

rockerc --force
rockerc --vsc --force

Environment Variables

You can tune startup wait timing (useful on slower hosts) with:

  • ROCKERC_WAIT_TIMEOUT (default: 20 seconds)
  • ROCKERC_WAIT_INTERVAL (default: 0.25 seconds)

Create Dockerfile Artifacts

If you include create-dockerfile in args or pass --create-dockerfile, a Dockerfile.rocker and run_dockerfile.sh script are generated using rocker's dry-run output.

Notes & Caveats

  • Using --rm in custom extra args is discouraged with --vsc since closing the shell would remove the container out from under VS Code.
  • The volume mount path is standardized to /workspaces/<container> to match VS Code's remote container expectations.
  • Existing behavior of merging & deduplicating extensions (args) and blacklist remains unchanged.

Motivation

Rocker is an alternative to docker-compose that makes it easier to run containers with access to features of the local environment and add extra capabilities to existing docker images. However rocker has many configurable options and it can get hard to read or reuse those arguments. This is a naive wrapper that read a rockerc.yaml file and passes them to rocker. There are currently no plans to integrate docker-compose like functionality directly into rocker so I made this as a proof of concept to see what the ergonomics of it would be like.

Caveats

I'm not sure this is the best way of implementing rockerc like functionality. It might be better to implemented it as a rocker extension, or in rocker itself. This was just the simplest way to get started. I may explore those other options in more detail in the future.

rocker.yaml configuration

You need to pass either a docker image, or a relative path to a dockerfile

rockerc.yaml

image: ubuntu:22.04

or

dockerfile: Dockerfile

will look for the dockerfile relative to the rockerc.yaml file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rockerc-0.13.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rockerc-0.13.0-py2.py3-none-any.whl (12.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file rockerc-0.13.0.tar.gz.

File metadata

  • Download URL: rockerc-0.13.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for rockerc-0.13.0.tar.gz
Algorithm Hash digest
SHA256 ab876cf6a2c413b219ac5a834e378dbcc99f628e28e6f836bd80b2cc7b70400e
MD5 4a5d00f8388f4b0310b57b568cd41dbd
BLAKE2b-256 d963e7e61908563b425b032ce98b365f706a5f5b7870ec949d341c2155ec554c

See more details on using hashes here.

File details

Details for the file rockerc-0.13.0-py2.py3-none-any.whl.

File metadata

  • Download URL: rockerc-0.13.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for rockerc-0.13.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 66f3075e9c8dfc67ec96a8f37dbc4c1c693fde93011f3e3b6d17e1fbd69017c6
MD5 1dfe4022ac1d65db84fd026e1aebc289
BLAKE2b-256 863d71f9b98ffca3cafb5794526ffc7a67a648e7b209096b3dd02054f2216624

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page