eeshugerman / postgres-backup-s3

A handy Docker container to periodically backup PostgreSQL to S3
MIT License
485 stars 167 forks source link

Error while removing container with remote Docker context #22

Open ldeluigi opened 2 years ago

ldeluigi commented 2 years ago

Containers running this image throw errors when trying to remove them through docker compose down:

Delete "http://docker.example.com/v1.41/containers/00faf040af3d961331a939748b80e9cc151f18034b89a0cb194daee42990abd6?force=1&v=1": command [ssh -l ubuntu -- 3.234.133.243 docker system dial-stdio] has exited with exit status 1, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=

Maybe it lacks a proper SIGTERM handling?

eeshugerman commented 2 years ago

I'm unable to reproduce this. Am I doing it right?

❯ docker compose  up -d
[+] Running 2/2
 ⠿ Container postgres-backup-s3-backup-1    Started                                                                                                                                                                                     0.5s
 ⠿ Container postgres-backup-s3-postgres-1  Started                                                                                                                                                                                     0.5s

❯ docker compose down
[+] Running 3/3
 ⠿ Container postgres-backup-s3-postgres-1  Removed                                                                                                                                                                                     0.3s
 ⠿ Container postgres-backup-s3-backup-1    Removed                                                                                                                                                                                     0.2s
 ⠿ Network postgres-backup-s3_default       Removed                                                                                                                                                                                     0.2s

❯ echo $?
0

Please provide your docker-compose.yml (with secrets redacted of course).

ldeluigi commented 2 years ago

I'm using multiple compose files. Here are two of them:

version: '3.8'

services:
  web:
    build:
      context: .
      args:
        SECRET_KEY: ${SECRET_KEY:?}
    image: spellbook-backend
    expose:
      - 8000
    depends_on:
      - db
    volumes:
      - static_volume:/home/app/web/staticfiles:rw
    environment:
      SQL_ENGINE: django.db.backends.postgresql
      SQL_DATABASE: spellbook_db_prod
      SQL_USER: ${DB_USER:?}
      SQL_PASSWORD: ${DB_PASSWORD:?}
      SQL_HOST: db
      SQL_PORT: 5432
      DATABASE: postgres
    restart: always
  nginx:
    build:
      context: ./nginx
      target: base
    image: spellbook-nginx
    ports:
      - 80:80
    depends_on:
      - web
    volumes:
      - static_volume:/home/app/web/staticfiles:ro
    restart: always
  db:
    image: postgres:14-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    expose:
      - 5432
    environment:
      PGPORT: 5432
      POSTGRES_USER: ${DB_USER:?}
      POSTGRES_PASSWORD: ${DB_PASSWORD:?}
      POSTGRES_DB: spellbook_db_prod
    restart: always
volumes:
  static_volume:
  postgres_data:
version: '3.8'

services:
  db-backups:
    image: eeshugerman/postgres-backup-s3:14
    depends_on:
      - db
    environment:
      SCHEDULE: '@daily'
      S3_REGION: ${AWS_S3_REGION:?}
      S3_ACCESS_KEY_ID: ${AWS_S3_ACCESS_KEY_ID:?}
      S3_SECRET_ACCESS_KEY: ${AWS_S3_SECRET_ACCESS_KEY:?}
      S3_BUCKET: ${AWS_S3_BUCKET:?}
      S3_PREFIX: backup
      POSTGRES_BACKUP_ALL: 'false'
      POSTGRES_HOST: db
      POSTGRES_DATABASE: spellbook_db_prod
      POSTGRES_USER: ${DB_USER:?}
      POSTGRES_PASSWORD: ${DB_PASSWORD:?}
      POSTGRES_EXTRA_OPTS: ''
    restart: always
eeshugerman commented 2 years ago

Hi, sorry for the slow response. I don't think this is related, but I'll note I don't recognize the POSTGRES_BACKUP_ALL and POSTGRES_EXTRA_OPTS environment variables. Otherwise I don't see anything of note.

Are you able to reproduce the issue with plain Docker Compose on a local machine? I don't entirely understand the error message you provided -- why does it have a URL on it?

ldeluigi commented 2 years ago

Are you able to reproduce the issue with plain Docker Compose on a local machine? I don't entirely understand the error message you provided -- why does it have a URL on it?

I'm not. I'm using a Docker context on a remote machine (hence the url). Idk why it starts with the example domain. When I find the time I'll try to create a minimal reproducible example. In local I can't reproduce it (everything seems fine)