[GH-ISSUE #69] Autostart containers on server reboot #56

Open
opened 2026-02-26 21:34:13 +03:00 by kerem · 1 comment
Owner

Originally created by @draconMo on GitHub (Dec 19, 2024).
Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/69

Hello
we have docker-compose.yml with the following content

root@mail:~/pgweb# cat docker-compose.yml
services:
pgbackweb:
image: eduardolat/pgbackweb:latest
restart: unless-stopped
ports:
- "8085:8085" # Access the web interface at http://localhost:8085
volumes:
- ./backups:/backups # If you only use S3 destinations, you don't need this volume
environment:
PBW_ENCRYPTION_KEY: "my_secret_key" # Change this to a strong key
PBW_POSTGRES_CONN_STRING: "postgresql://postgres:password@postgres:5432/pgbackweb?sslmode=disable"
TZ: "America/Guatemala" # Set your timezone, optional
depends_on:
postgres:
condition: service_healthy

postgres:
image: postgres:16
environment:
POSTGRES_USER: postgres
POSTGRES_DB: pgbackweb
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
volumes:
- ./data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

root@mail:~/pgweb# docker compose up -d

[+] Running 2/2
✔ Container pgweb-postgres-1 Healthy
✔ Container pgweb-pgbackweb-1 Started
containers are being stratified, everything is ok.

the task is to launch containers upon reboot (turning on after shutting down the server)
I add restart: always to docker-compose.yml

services:
pgbackweb:
image: eduardolat/pgbackweb:latest
restart: always
ports:
- "8085:8085" # Access the web interface at http://localhost:8085
volumes:
- ./backups:/backups # If you only use S3 destinations, you don't need this volume
environment:
PBW_ENCRYPTION_KEY: "my_secret_key" # Change this to a strong key
PBW_POSTGRES_CONN_STRING: "postgresql://postgres:password@postgres:5432/pgbackweb?sslmode=disable"
TZ: "America/Guatemala" # Set your timezone, optional
depends_on:
postgres:
condition: service_healthy

postgres:
image: postgres:16
environment:
POSTGRES_USER: postgres
POSTGRES_DB: pgbackweb
POSTGRES_PASSWORD: password
ports:
- "5432:5432"
volumes:
- ./data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5

And the trouble/sadness is that the containers don’t start.

Tell me what I did wrong and how to do it correctly?

Originally created by @draconMo on GitHub (Dec 19, 2024). Original GitHub issue: https://github.com/eduardolat/pgbackweb/issues/69 Hello we have docker-compose.yml with the following content </code> root@mail:~/pgweb# cat docker-compose.yml services: pgbackweb: image: eduardolat/pgbackweb:latest restart: unless-stopped ports: - "8085:8085" # Access the web interface at http://localhost:8085 volumes: - ./backups:/backups # If you only use S3 destinations, you don't need this volume environment: PBW_ENCRYPTION_KEY: "my_secret_key" # Change this to a strong key PBW_POSTGRES_CONN_STRING: "postgresql://postgres:password@postgres:5432/pgbackweb?sslmode=disable" TZ: "America/Guatemala" # Set your timezone, optional depends_on: postgres: condition: service_healthy postgres: image: postgres:16 environment: POSTGRES_USER: postgres POSTGRES_DB: pgbackweb POSTGRES_PASSWORD: password ports: - "5432:5432" volumes: - ./data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s timeout: 5s retries: 5 </code> root@mail:~/pgweb# docker compose up -d </code> [+] Running 2/2 ✔ Container pgweb-postgres-1 Healthy ✔ Container pgweb-pgbackweb-1 Started containers are being stratified, everything is ok. </code> the task is to launch containers upon reboot (turning on after shutting down the server) I add restart: always to docker-compose.yml </code> services: pgbackweb: image: eduardolat/pgbackweb:latest restart: always ports: - "8085:8085" # Access the web interface at http://localhost:8085 volumes: - ./backups:/backups # If you only use S3 destinations, you don't need this volume environment: PBW_ENCRYPTION_KEY: "my_secret_key" # Change this to a strong key PBW_POSTGRES_CONN_STRING: "postgresql://postgres:password@postgres:5432/pgbackweb?sslmode=disable" TZ: "America/Guatemala" # Set your timezone, optional depends_on: postgres: condition: service_healthy postgres: image: postgres:16 environment: POSTGRES_USER: postgres POSTGRES_DB: pgbackweb POSTGRES_PASSWORD: password ports: - "5432:5432" volumes: - ./data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s timeout: 5s retries: 5 </code> And the trouble/sadness is that the containers don’t start. Tell me what I did wrong and how to do it correctly?
Author
Owner

@draconMo commented on GitHub (Dec 20, 2024):

problem solving
add
restart: always
in both containers

services:
pgbackweb:
image: eduardolat/pgbackweb:latest
restart: always
..............
postgres:
image: postgres:16
restart: always
............
then
ocker compose up -d

after reboot (containers are started at boot).

<!-- gh-comment-id:2557013000 --> @draconMo commented on GitHub (Dec 20, 2024): problem solving add restart: always in both containers services: pgbackweb: image: eduardolat/pgbackweb:latest restart: always .............. postgres: image: postgres:16 restart: always ............ then ocker compose up -d after reboot (containers are started at boot).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/pgbackweb#56
No description provided.