How to backup localhost databases
Learn how to configure Postgresus to backup PostgreSQL databases running on your host machine (localhost) when using Docker.
The problem
If you're running Postgresus in Docker and want to back up databases running on your host machine (localhost), you need to configure Docker to use host network mode.
By default, Docker containers run in an isolated network and cannot access services on localhost. The host network mode allows the container to share the host's network namespace.
Solution for Docker Compose
Update your docker-compose.yml file to use network_mode: host:
services:
postgresus:
container_name: postgresus
image: rostislavdugin/postgresus:latest
network_mode: host
volumes:
- ./postgresus-data:/postgresus-data
restart: unless-stoppedSolution for Docker run
Use the --network host flag:
docker run -d \
--name postgresus \
--network host \
-v ./postgresus-data:/postgresus-data \
--restart unless-stopped \
rostislavdugin/postgresus:latest💡 Note: When using host network mode, you can connect to your localhost database using 127.0.0.1 or localhost as the host in your Postgresus backup configuration. You'll also access the Postgresus UI directly at http://localhost:4005 without port mapping.
⚠️ Important for Windows and macOS users: The host network mode only works natively on Linux. On Windows and macOS, Docker runs inside a Linux VM, so host.docker.internal should be used instead of localhost as the database host address in your backup configuration.