It's the starting point. Production must explain every resource.
Local Compose Always include source mount, development port,latest Mirrors and default passwords, which become uncertain when they are produced. environment Change it to production It ends by answering where the mirror comes from, where the data are, how the container communicates, how the failure is discovered and how the version is returned. Keep the base first. compose.yaml Again. compose.production.yaml Covers the difference in production. The boundaries of the development configuration and the production configuration can be reviewed without having to copy two complete documents that are gradually dispersing.
Mirrors should be recognizable without drifting latest
Use a clear version or immutable digest, for example, myapp:2026-08-14 Not every pull means something different. latest. If built on the server, fixed base mirrors and lock files and confirmed that the construction context is not used .env, databases and backups are entered into the mirror. A more secure process is to build and push into the controlled environment and then the server pulls the same mirror. Record mirrors ID and the release version. What is needed to roll back is the previous authenticated mirror, not the re-constructing of the old code, because the base mirror and the dependencies may have changed.
Only send the back-to-the-agent required port to the server.
Apply host Caddy When acting, the ring address may be tied back:
services:
app:
image: registry.example.com/myapp:2026-08-14
ports:
- "127.0.0.1:3000:3000"
restart: unless-stoppedDatabase not required ports# Through # Compose The internal network is connected by the service name. EXPOSE It's not the same thing. It's the end. ss -lntp and docker compose ps Check the host for actual listening.
The permanent roll must be backed up and restored.
Lists all written locations: databases, uploads, search indexes, queues, and applications to generate files. Binding the mounted loads to specify host path and permissions, and naming files to know how physical data are backed up. Deleting containers should not remove data, but docker compose down -v Volumes would be deleted, and production manuals would have to be explicitly prohibited from being applied at will. Loads read-only configurations separately from persistent data. root When the user runs, handles the directory owner in advance, and puts it in the directory if there is a bug in access chmod 777.
A health check needs to verify service capability.
Process exists without a response. Application provides a lightweight /health, check that the key initialization is complete, but do not perform expensive database round tables every few seconds.Compose (a) A reasonable interval, overtime, retry and start-up grace for a health examination:
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:3000/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 20sNot in the mirror. wget Instead, you can't copy it and pretend that the check takes effect. Recourse to the start-up sequence will only reduce competition and not replace the application of its own re-testing and mishandling.
Render the final configuration first and then start.
docker compose -f compose.yaml -f compose.production.yaml config
docker compose -f compose.yaml -f compose.production.yaml pull
docker compose -f compose.yaml -f compose.production.yaml up -d
docker compose ps
docker compose logs --tail=100 appconfig The output exposes the final port, volume, and variable sources, and the check is done with care not to copy sensitive values to the worksheet.Caddy Domain name and key business path three-tier validation.
Both updates and rollbacks are ordered in advance.
Backup data before release, pull new versions, wait for health after startup, switch or continue service. Change mirror labels back to the previous version and re-set when failure up Not on the spot. Git Submits for construction. The database migration must assess backward compatibility, and data changes that cannot roll back require expansion, switching and final clean-up. The criteria for completion are: the mirror is immutable, the lowest open port is open, there is a list of persistent data, the health check is genuinely available, the final configuration is viewed, and the previous version of the mirror is still valid.Production environment key management.