tool-containers
Menu
GitHub (opens in new tab)

Run core with Docker

run.sh opens a shell in core with the current directory mounted at /workspace. Dockerfile.example shows core as the base of your own image.

Images
  • GHCRghcr.io/hambn/core
  • Docker Hubdocker.io/hambn/core
Use case
Throwaway shell or base for your own image
Source
tools/base/core/docs/docker (opens in new tab)
On this page

Prerequisites

  • Docker Engine 23 or later.

Open a shell

Shell
./run.sh

Arguments replace the shell, so you can run one command:

Shell
./run.sh curl -fsS https://example.com -o /dev/null -w '%{http_code}\n'

Build your own image

Put an app.sh next to Dockerfile.example, then:

Shell
docker build -f Dockerfile.example -t my-app .
docker run --rm my-app

core has no sudo and no setuid binaries. To install packages, switch to USER root in your Dockerfile, install them, then switch back with USER 65532:65532.

Variables

Variable Required Purpose
CORE_IMAGE no Image run.sh runs. Defaults to ghcr.io/hambn/core:wolfi; use the alpine or ubuntu tag, or ghcr.io/hambn/core@sha256:<digest> to pin one build.

Workspace

run.sh mounts the current directory at /workspace and starts there. The container runs as nonroot (UID and GID 65532), so that UID must be able to read the directory, and write to it if your command writes.

Files

File contents

Dockerfile.example4 lines
# docker build -f Dockerfile.example -t my-app .
FROM ghcr.io/hambn/core:wolfi
COPY --chown=65532:65532 app.sh /home/nonroot/app.sh
CMD ["bash", "/home/nonroot/app.sh"]
run.sh9 lines
#!/usr/bin/env bash
# Open a core shell, or run one command, with the current directory at /workspace.
set -euo pipefail

image=${CORE_IMAGE:-ghcr.io/hambn/core:wolfi}
docker run -it --rm \
    -v "$PWD:/workspace" \
    -w /workspace \
    "$image" "$@"

Topics