Docker Image packaging for OpenSSH providing standardized container foundations with flexible entrypoint systems, multi-architecture support, and consistent configuration patterns across Alpine, Debian, and Rocky Linux distributions.
This Docker image provides a secure, flexible, and ready-to-use OpenSSH server. It provides:
- Pre-configured OpenSSH Server with sensible defaults and multi-architecture support
- Standardized Dockerfiles with OCI annotations and best practices
- Flexible entrypoint system supporting custom initialization scripts
- Consistent environment variable configuration across all variants
- Three distribution variants: Alpine (lightweight), Debian (default/widely-compatible), Rocky (enterprise)
This image runs an OpenSSH server. You can configure it by mounting your authorized keys or custom configuration files.
The most secure way to use this container is by mounting your public key to the authorized_keys file.
docker run -d --name=openssh -e TZ=Asia/Shanghai -p 22:22 -v ~/.ssh/id_rsa.pub:/root/.ssh/authorized_keys:ro --restart unless-stopped snowdreamtech/openssh:latestYou can then log in using:
ssh root@localhost -p 22When the container starts for the first time without the SSH_ROOT_CRED environment variable, it automatically generates a random root password and prints it to the logs (Generate random ssh root password: ...). You can find it by running docker logs openssh.
If you want to set a fixed password, you can pass it via the SSH_ROOT_CRED environment variable, or change it in the running container:
# Start the container
docker run -d --name=openssh -p 22:22 snowdreamtech/openssh:latest
# Set root password
docker exec -it openssh sh -c "echo 'root:your_secure_password' | chpasswd"If you want to use your own sshd_config or provide host keys to prevent SSH warnings when the container is recreated:
docker run -d --name=openssh -p 22:22 -v /my/custom/sshd_config:/etc/ssh/sshd_config:ro -v /my/host/keys:/etc/ssh/ snowdreamtech/openssh:latestservices:
openssh:
image: snowdreamtech/openssh:latest
container_name: openssh
ports:
- '22:22'
environment:
- TZ=Asia/Shanghai
volumes:
- ~/.ssh/id_rsa.pub:/root/.ssh/authorized_keys:ro
- ./data:/data
restart: unless-stoppedThe recommended variant for most use cases, providing wide compatibility and extensive package availability.
docker run -d \
--name=openssh \
-e TZ=Asia/Shanghai \
-p 22:22 \
--restart unless-stopped \
snowdreamtech/openssh:debianSupported Architectures: amd64, arm32v7, arm64, ppc64le, riscv64, s390x
Base Image: snowdreamtech/debian:13.6.0
Lightweight variant optimized for minimal image size and fast startup times.
docker run -d \
--name=openssh \
-e TZ=Asia/Shanghai \
-p 22:22 \
--restart unless-stopped \
snowdreamtech/openssh:alpineSupported Architectures: 386, amd64, arm/v6, arm/v7, arm64, ppc64le, riscv64, s390x
Base Image: snowdreamtech/alpine:3.24.1
Enterprise-focused variant based on Rocky Linux, ideal for production environments requiring RHEL compatibility.
docker run -d \
--name=openssh \
-e TZ=Asia/Shanghai \
-p 22:22 \
--restart unless-stopped \
snowdreamtech/openssh:rockySupported Architectures: amd64, arm64, ppc64le, s390x
Base Image: snowdreamtech/rocky:10.2.0
# Build Debian variant
docker build -t snowdreamtech/base:debian ./docker/debian/
# Build Alpine variant
docker build -t snowdreamtech/base:alpine ./docker/alpine/
# Build Rocky variant
docker build -t snowdreamtech/base:rocky ./docker/rocky/Build images for multiple architectures using docker buildx:
# Create and use a buildx builder
docker buildx create --use --name build --node build --driver-opt network=host
# Build Debian for multiple architectures
docker buildx build \
--platform=linux/386,linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x \
-t snowdreamtech/base:debian \
./docker/debian/ \
--push
# Build Alpine for multiple architectures
docker buildx build \
--platform=linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x \
-t snowdreamtech/base:alpine \
./docker/alpine/ \
--push
# Build Rocky for multiple architectures
docker buildx build \
--platform=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x \
-t snowdreamtech/base:rocky \
./docker/rocky/ \
--pushAll variants support the following environment variables for runtime configuration:
| Variable | Default | Description |
|---|---|---|
KEEPALIVE |
0 |
Keep container running (1=enabled, 0=disabled) |
CAP_NET_BIND_SERVICE |
0 |
Enable binding to privileged ports (<1024) |
LANG |
C.UTF-8 |
Locale setting for UTF-8 character support |
UMASK |
022 |
Default file creation mask |
DEBUG |
false |
Enable debug output in entrypoint scripts |
PGID |
0 |
Primary group ID for custom user creation |
PUID |
0 |
User ID for custom user creation |
USER |
root |
Username for custom user creation |
WORKDIR |
/root |
Working directory path |
TZ |
- | Timezone (e.g., Asia/Shanghai, America/New_York) |
Debian-specific:
| Variable | Default | Description |
|---|---|---|
DEBIAN_FRONTEND |
noninteractive |
Debian package installation mode |
Images follow semantic versioning with the format: {major}.{minor}.{patch}-{variant}
Examples:
snowdreamtech/openssh:10.0.2-debiansnowdreamtech/openssh:10.3.2-alpinesnowdreamtech/openssh:9.9.2-rocky
This format allows:
- Full version pinning:
10.0.2-debian(exact version) - Variant latest tag:
latest-debian(tracks most recent release for Debian) - Global latest tag:
latest(tracks most recent release, defaults to Debian)
Each distribution variant supports multiple CPU architectures for deployment across diverse hardware platforms:
| Variant | Architectures |
|---|---|
| Debian | amd64, arm32v7, arm64, ppc64le, riscv64, s390x |
| Alpine | i386, amd64, arm32v6, arm32v7, arm64, ppc64le, riscv64, s390x |
| Rocky | amd64, arm64, ppc64le, s390x |
Docker automatically selects the appropriate architecture for your platform when pulling images.
The base template includes a flexible entrypoint system that executes custom initialization scripts before starting your application.
- The
docker-entrypoint.shscript runs at container startup - It executes all executable scripts in
/usr/local/bin/entrypoint.d/in lexical order - Each script receives the container's command-line arguments
- If any script fails, the container stops (fail-fast behavior)
Create custom initialization scripts in your derived Dockerfile:
FROM snowdreamtech/base:debian
# Add your custom initialization script
COPY my-init.sh /usr/local/bin/entrypoint.d/20-my-init.sh
RUN chmod +x /usr/local/bin/entrypoint.d/20-my-init.sh
# Your application setup
COPY app /app
CMD ["/app/start.sh"]Enable debug output to troubleshoot entrypoint execution:
docker run -e DEBUG=true snowdreamtech/base:debianOutput example:
→ [ENTRYPOINT] Executing all scripts in /usr/local/bin/entrypoint.d
→ Running /usr/local/bin/entrypoint.d/10-base-init.sh
→ [ENTRYPOINT] Done.
docker buildx create --use --name build --node build --driver-opt network=host
# Build Debian variant
docker buildx build -t snowdreamtech/openssh:debian --platform=linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x ./docker/debian/
# Build Alpine variant
docker buildx build -t snowdreamtech/openssh:alpine --platform=linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x ./docker/alpine/
# Build Rocky variant
docker buildx build -t snowdreamtech/openssh:rocky --platform=linux/amd64,linux/arm64,linux/ppc64le,linux/s390x ./docker/rocky/- 使用 buildx 构建多平台 Docker 镜像
- 如何使用 docker buildx 构建跨平台 Go 镜像
- Building Multi-Arch Images for Arm and x86 with Docker Desktop
- How to Rapidly Build Multi-Architecture Images with Buildx
- Faster Multi-Platform Builds: Dockerfile Cross-Compilation Guide
- docker/buildx
- Email: sn0wdr1am@qq.com
- QQ: 3217680847
- QQ群: 949022145
- WeChat/微信群: sn0wdr1am
MIT