Keep the live file private and unchanged
Create a separate copy for a support request, code review, example repository, or documentation. Do not replace a working value in the only copy you have. A shareable example is a new artifact with a narrower purpose.
1. Decide which names and structure the recipient actually needs
A recipient may need to see that a variable exists, how services are grouped, or which configuration keys are missing. They rarely need the live value. Keep names and necessary non-sensitive structure, then use clear placeholders such as YOUR_API_KEY rather than values that resemble a real credential.
You need a .env example
Compare variable names between configuration files and create a safe empty-value template rather than copying live values.
Compare .env keysYou need a Docker Compose environment block
Select only variable names for the Compose mapping; values should not be displayed or copied into the result.
Map .env names to Compose2. Replace secrets deliberately; do not rely on a guessed cleanup
Secrets can have unfamiliar names, and ordinary-looking fields can identify an internal service or person. Review the copy line by line for passwords, API keys, tokens, private keys, database URLs, certificates, internal hosts, email addresses, and file paths. If you cannot judge a value, do not share it until its owner approves.
- Use a descriptive non-working placeholder for a required field, not a transformed version of the live secret.
- Keep real values out of screenshots, terminal output, commits, tickets, and chat messages as well as the file itself.
- Rotate a credential through the appropriate service if you believe it was exposed; redacting a later copy does not undo an earlier share.
3. Preserve supported structure without revealing the value
Some formats have their own structure. A Kubernetes Secret, for example, encodes values but does not make them safe to disclose. An API definition can expose endpoints intended only for internal use. Choose a tool that keeps the structural decision visible instead of silently rewriting unrelated parts.
Kubernetes Secret YAML
Review supported Base64 text values locally and keep unsupported fields visible instead of assuming every value can be safely changed.
Review a Kubernetes SecretPublic API specification
Remove selected internal paths and then check schema references before sharing a reduced OpenAPI JSON specification.
Prune an OpenAPI specReview the exact copy that will leave your device
Read the final file as the recipient will see it. Check that required names remain, values are placeholders, and neither secrets nor internal-only details survived through comments or example URLs. Keep the original private after the handoff.
Common questions
Is Base64-encoded data safe to share?
No. Base64 is an encoding, not encryption. Treat an encoded Secret value as sensitive unless you know it contains no sensitive information.
Can I replace every value with an empty string?
Sometimes, but a recipient may need to know the expected kind of value. Use a clearly non-working placeholder when that makes the example easier to understand, and never reuse a real prefix or partial secret.
Does a secret scanner guarantee my copy is safe?
No. A scanner can find supported patterns, but it cannot know every private value, internal endpoint, or contextual detail. Manual review of the final copy remains necessary.
