-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Description
The official Docker image ghcr.io/swaggo/swag:latest cannot execute swag fmt command because the Go binary is not available inside the container.
Steps to Reproduce
- Pull the latest Docker image:
docker pull ghcr.io/swaggo/swag:latest- Try to run
swag fmt:
docker run --rm -v $(pwd):/code ghcr.io/swaggo/swag:latest fmtExpected Behavior
The swag fmt command should format Swagger comments in Go files.
Actual Behavior
2025/10/29 12:30:23 fmt: err: go command required, not found: exec: "go": executable file not found in $PATH: stderr:
Environment
- Docker image:
ghcr.io/swaggo/swag:latest - Image digest:
sha256:03c4d91c721789d904615a48b5c8d574c5ad90f11de39a783c368d4867533c4b - Host OS: macOS / Linux
- Docker version:
Docker version 24.x
Additional Context
The swag init command works fine in the same image, only swag fmt fails because it requires the Go toolchain.
Possible Solutions
- Include Go binary in the Docker image (similar to how other tools like
golangci-lintdo it) - Document this limitation in README with workarounds
- Provide separate images:
swag:latest(init only) andswag:full(with Go for fmt)
Workaround
Currently, users need to either:
- Use local
gofmtinstead ofswag fmt - Mount local Go binary into the container (complex setup)
- Build a custom image with Go included
Related
This affects CI/CD pipelines where users want to run both fmt and init in Docker without installing local dependencies.
Metadata
Metadata
Assignees
Labels
No labels