Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waiting for PostgreSQL database to become available... #7

Closed
webbpinner opened this issue Feb 3, 2023 · 12 comments
Closed

Waiting for PostgreSQL database to become available... #7

webbpinner opened this issue Feb 3, 2023 · 12 comments

Comments

@webbpinner
Copy link

webbpinner commented Feb 3, 2023

Purchased the course (very well done!) but I'm unable to successfully run the docker container as posted in this repo. The individual services appear to all start but the services dependent on the PostgreSQL database complain about not being able to connect to the service. Below is the output from my attempt:

% docker-compose up --build
[+] Building 1.0s (34/88)                                                                                                                                                                                                                                    
 => [fastapi_celery_example_celery_worker internal] load build definition from Dockerfile                                                                                                                                                               0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                     0.0s
 => [fastapi_celery_example_celery_flower internal] load build definition from Dockerfile                                                                                                                                                               0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                     0.0s
 => [fastapi_celery_example_celery_beat internal] load build definition from Dockerfile                                                                                                                                                                 0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                     0.0s
 => [fastapi_celery_example_web internal] load build definition from Dockerfile                                                                                                                                                                         0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                     0.0s
 => [fastapi_celery_example_celery_worker internal] load .dockerignore                                                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                                                                                         0.0s
 => [fastapi_celery_example_celery_flower internal] load .dockerignore                                                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                                                                                         0.0s
 => [fastapi_celery_example_celery_beat internal] load .dockerignore                                                                                                                                                                                    0.0s
 => => transferring context: 2B                                                                                                                                                                                                                         0.0s
 => [fastapi_celery_example_web internal] load .dockerignore                                                                                                                                                                                            0.0s
 => => transferring context: 2B                                                                                                                                                                                                                         0.0s
 => [fastapi_celery_example_celery_beat internal] load metadata for docker.io/library/python:3.10-slim-buster                                                                                                                                           0.7s
 => [fastapi_celery_example_celery_worker  1/20] FROM docker.io/library/python:3.10-slim-buster@sha256:8c2ff857fff9df7905b299647176e16c2a606ff65fa479ba9cad61acbee3123c                                                                                 0.0s
 => [fastapi_celery_example_celery_beat internal] load build context                                                                                                                                                                                    0.0s
 => => transferring context: 629B                                                                                                                                                                                                                       0.0s
 => [fastapi_celery_example_web internal] load build context                                                                                                                                                                                            0.0s
 => => transferring context: 629B                                                                                                                                                                                                                       0.0s
 => [fastapi_celery_example_celery_flower internal] load build context                                                                                                                                                                                  0.0s
 => => transferring context: 629B                                                                                                                                                                                                                       0.0s
 => [fastapi_celery_example_celery_worker internal] load build context                                                                                                                                                                                  0.0s
 => => transferring context: 629B                                                                                                                                                                                                                       0.0s
 => [fastapi_celery_example_web] exporting to image                                                                                                                                                                                                     0.0s
 => => exporting layers                                                                                                                                                                                                                                 0.0s
 => => writing image sha256:e3a7e9487101b2899f1d8384bdaa80245321f9d1527afedc3137d17ab36ea9e9                                                                                                                                                            0.0s
 => => writing image sha256:7408b983e9239811ea2e85c2ec545d5ad6a27f7e983d84550824e047d1ca5fa5                                                                                                                                                            0.0s
 => => writing image sha256:81964658771733f0def1f081ebd3ae18a9d79f89403f4ebca7f4d21a22cb3b22                                                                                                                                                            0.0s
 => => naming to docker.io/library/fastapi_celery_example_celery_flower                                                                                                                                                                                 0.0s
 => => naming to docker.io/library/fastapi_celery_example_celery_worker                                                                                                                                                                                 0.0s
 => => naming to docker.io/library/fastapi_celery_example_celery_beat                                                                                                                                                                                   0.0s
 => => writing image sha256:a1c308cbb9ac5221e8b2961a190f2123e9d35a633f2d4563ef93d7e0537835da                                                                                                                                                            0.0s
 => => naming to docker.io/library/fastapi_celery_example_web                                                                                                                                                                                           0.0s
 => CACHED [fastapi_celery_example_celery_beat  2/20] RUN apt-get update   && apt-get install -y build-essential   && apt-get install -y libpq-dev   && apt-get install -y telnet netcat   && apt-get purge -y --auto-remove -o APT::AutoRemove::Recom  0.0s
 => CACHED [fastapi_celery_example_celery_beat  3/20] COPY ./requirements.txt /requirements.txt                                                                                                                                                         0.0s
 => CACHED [fastapi_celery_example_celery_beat  4/20] RUN pip install -r /requirements.txt                                                                                                                                                              0.0s
 => CACHED [fastapi_celery_example_celery_beat  5/20] COPY ./compose/local/fastapi/entrypoint /entrypoint                                                                                                                                               0.0s
 => CACHED [fastapi_celery_example_celery_beat  6/20] RUN sed -i 's/\r$//g' /entrypoint                                                                                                                                                                 0.0s
 => CACHED [fastapi_celery_example_celery_beat  7/20] RUN chmod +x /entrypoint                                                                                                                                                                          0.0s
 => CACHED [fastapi_celery_example_celery_beat  8/20] COPY ./compose/local/fastapi/start /start                                                                                                                                                         0.0s
 => CACHED [fastapi_celery_example_celery_beat  9/20] RUN sed -i 's/\r$//g' /start                                                                                                                                                                      0.0s
 => CACHED [fastapi_celery_example_celery_beat 10/20] RUN chmod +x /start                                                                                                                                                                               0.0s
 => CACHED [fastapi_celery_example_celery_beat 11/20] COPY ./compose/local/fastapi/celery/worker/start /start-celeryworker                                                                                                                              0.0s
 => CACHED [fastapi_celery_example_celery_beat 12/20] RUN sed -i 's/\r$//g' /start-celeryworker                                                                                                                                                         0.0s
 => CACHED [fastapi_celery_example_celery_beat 13/20] RUN chmod +x /start-celeryworker                                                                                                                                                                  0.0s
 => CACHED [fastapi_celery_example_celery_beat 14/20] COPY ./compose/local/fastapi/celery/beat/start /start-celerybeat                                                                                                                                  0.0s
 => CACHED [fastapi_celery_example_celery_beat 15/20] RUN sed -i 's/\r$//g' /start-celerybeat                                                                                                                                                           0.0s
 => CACHED [fastapi_celery_example_celery_beat 16/20] RUN chmod +x /start-celerybeat                                                                                                                                                                    0.0s
 => CACHED [fastapi_celery_example_celery_beat 17/20] COPY ./compose/local/fastapi/celery/flower/start /start-flower                                                                                                                                    0.0s
 => CACHED [fastapi_celery_example_celery_beat 18/20] RUN sed -i 's/\r$//g' /start-flower                                                                                                                                                               0.0s
 => CACHED [fastapi_celery_example_celery_beat 19/20] RUN chmod +x /start-flower                                                                                                                                                                        0.0s
 => CACHED [fastapi_celery_example_celery_beat 20/20] WORKDIR /app                                                                                                                                                                                      0.0s
[+] Running 6/6
 ⠿ Container fastapi-celery-project-redis-1          Created                                                                                                                                                                                            0.0s
 ⠿ Container fastapi-celery-project-db-1             Recreated                                                                                                                                                                                          0.0s
 ⠿ Container fastapi-celery-project-celery_worker-1  Recreated                                                                                                                                                                                          0.1s
 ⠿ Container fastapi-celery-project-flower-1         Recreated                                                                                                                                                                                          0.1s
 ⠿ Container fastapi-celery-project-celery_beat-1    Recreated                                                                                                                                                                                          0.1s
 ⠿ Container fastapi-celery-project-web-1            Recreated                                                                                                                                                                                          0.1s
Attaching to fastapi-celery-project-celery_beat-1, fastapi-celery-project-celery_worker-1, fastapi-celery-project-db-1, fastapi-celery-project-flower-1, fastapi-celery-project-redis-1, fastapi-celery-project-web-1
fastapi-celery-project-redis-1          | 1:C 03 Feb 2023 12:13:33.967 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
fastapi-celery-project-redis-1          | 1:C 03 Feb 2023 12:13:33.967 # Redis version=7.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
fastapi-celery-project-redis-1          | 1:C 03 Feb 2023 12:13:33.967 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.967 * monotonic clock: POSIX clock_gettime
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.968 * Running mode=standalone, port=6379.
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.968 # Server initialized
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.973 * Loading RDB produced by version 7.0.8
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.973 * RDB age 3 seconds
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.973 * RDB memory usage when created 0.85 Mb
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.973 * Done loading RDB, keys loaded: 0, keys expired: 0.
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.974 * DB loaded from disk: 0.000 seconds
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 12:13:33.974 * Ready to accept connections
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | PostgreSQL Database directory appears to contain a database; Skipping initialization
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | 2023-02-03 12:13:34.008 UTC [1] LOG:  starting PostgreSQL 14.6 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
fastapi-celery-project-db-1             | 2023-02-03 12:13:34.008 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
fastapi-celery-project-db-1             | 2023-02-03 12:13:34.008 UTC [1] LOG:  listening on IPv6 address "::", port 5432
fastapi-celery-project-db-1             | 2023-02-03 12:13:34.009 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fastapi-celery-project-db-1             | 2023-02-03 12:13:34.012 UTC [22] LOG:  database system was shut down at 2023-02-03 12:13:30 UTC
fastapi-celery-project-db-1             | 2023-02-03 12:13:34.015 UTC [1] LOG:  database system is ready to accept connections
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...

Perhaps I missed a step in the container setup?

@michael-yin
Copy link
Contributor

@webbpinner

I guess you are running the app on M1/M2 Mac?

The postgres docker image we use is x86/amd64, to make it work on M1/M2 Mac, we should use Arm Docker image

Could you please update the posgres image in docker-compose.yml to image: arm64v8/postgres:14-alpine and see if it works?

Thx.

@webbpinner
Copy link
Author

Thank you for your prompt reply. Unfortunately that does not appear to have fixed the issue. Here is the updated docker-compose output:

% docker-compose up --build
[+] Running 15/15
 ⠿ redis Pulled                                                                                                                                                                                                                                               11.0s
   ⠿ d60c5bfc4515 Pull complete                                                                                                                                                                                                                                4.1s
   ⠿ d6b470822c93 Pull complete                                                                                                                                                                                                                                4.6s
   ⠿ dee56d96db71 Pull complete                                                                                                                                                                                                                                9.3s
   ⠿ db2490ced130 Pull complete                                                                                                                                                                                                                                9.3s
   ⠿ 342fc15b09ef Pull complete                                                                                                                                                                                                                                9.4s
 ⠿ db Pulled                                                                                                                                                                                                                                                  52.9s
   ⠿ a9eaa45ef418 Pull complete                                                                                                                                                                                                                                4.1s
   ⠿ 6004074ad02a Pull complete                                                                                                                                                                                                                                4.1s
   ⠿ 690395976a32 Pull complete                                                                                                                                                                                                                                4.1s
   ⠿ 73fa4f129f16 Pull complete                                                                                                                                                                                                                               51.4s
   ⠿ 0a7be7d8ad8b Pull complete                                                                                                                                                                                                                               51.5s
   ⠿ 96306ea206e7 Pull complete                                                                                                                                                                                                                               51.5s
   ⠿ b5037d9b606d Pull complete                                                                                                                                                                                                                               51.6s
   ⠿ 642fbc6f316e Pull complete                                                                                                                                                                                                                               51.6s
[+] Building 0.7s (34/88)                                                                                                                                                                                                                                           
 => [fastapi_celery_example_web internal] load build definition from Dockerfile                                                                                                                                                                                0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                            0.0s
 => [fastapi_celery_example_celery_beat internal] load build definition from Dockerfile                                                                                                                                                                        0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                            0.0s
 => [fastapi_celery_example_celery_flower internal] load build definition from Dockerfile                                                                                                                                                                      0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                            0.0s
 => [fastapi_celery_example_celery_worker internal] load build definition from Dockerfile                                                                                                                                                                      0.0s
 => => transferring dockerfile: 32B                                                                                                                                                                                                                            0.0s
 => [fastapi_celery_example_web internal] load .dockerignore                                                                                                                                                                                                   0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                0.0s
 => [fastapi_celery_example_celery_beat internal] load .dockerignore                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                0.0s
 => [fastapi_celery_example_celery_flower internal] load .dockerignore                                                                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                0.0s
 => [fastapi_celery_example_celery_worker internal] load .dockerignore                                                                                                                                                                                         0.0s
 => => transferring context: 2B                                                                                                                                                                                                                                0.0s
 => [fastapi_celery_example_web internal] load metadata for docker.io/library/python:3.10-slim-buster                                                                                                                                                          0.4s
 => [fastapi_celery_example_celery_beat  1/20] FROM docker.io/library/python:3.10-slim-buster@sha256:8c2ff857fff9df7905b299647176e16c2a606ff65fa479ba9cad61acbee3123c                                                                                          0.0s
 => [fastapi_celery_example_celery_worker internal] load build context                                                                                                                                                                                         0.0s
 => => transferring context: 629B                                                                                                                                                                                                                              0.0s
 => [fastapi_celery_example_web internal] load build context                                                                                                                                                                                                   0.0s
 => => transferring context: 629B                                                                                                                                                                                                                              0.0s
 => [fastapi_celery_example_celery_flower internal] load build context                                                                                                                                                                                         0.0s
 => => transferring context: 629B                                                                                                                                                                                                                              0.0s
 => [fastapi_celery_example_celery_beat internal] load build context                                                                                                                                                                                           0.0s
 => => transferring context: 629B                                                                                                                                                                                                                              0.0s
 => CACHED [fastapi_celery_example_celery_worker  2/20] RUN apt-get update   && apt-get install -y build-essential   && apt-get install -y libpq-dev   && apt-get install -y telnet netcat   && apt-get purge -y --auto-remove -o APT::AutoRemove::Recommends  0.0s
 => CACHED [fastapi_celery_example_celery_worker  3/20] COPY ./requirements.txt /requirements.txt                                                                                                                                                              0.0s
 => CACHED [fastapi_celery_example_celery_worker  4/20] RUN pip install -r /requirements.txt                                                                                                                                                                   0.0s
 => CACHED [fastapi_celery_example_celery_worker  5/20] COPY ./compose/local/fastapi/entrypoint /entrypoint                                                                                                                                                    0.0s
 => CACHED [fastapi_celery_example_celery_worker  6/20] RUN sed -i 's/\r$//g' /entrypoint                                                                                                                                                                      0.0s
 => CACHED [fastapi_celery_example_celery_worker  7/20] RUN chmod +x /entrypoint                                                                                                                                                                               0.0s
 => CACHED [fastapi_celery_example_celery_worker  8/20] COPY ./compose/local/fastapi/start /start                                                                                                                                                              0.0s
 => CACHED [fastapi_celery_example_celery_worker  9/20] RUN sed -i 's/\r$//g' /start                                                                                                                                                                           0.0s
 => CACHED [fastapi_celery_example_celery_worker 10/20] RUN chmod +x /start                                                                                                                                                                                    0.0s
 => CACHED [fastapi_celery_example_celery_worker 11/20] COPY ./compose/local/fastapi/celery/worker/start /start-celeryworker                                                                                                                                   0.0s
 => CACHED [fastapi_celery_example_celery_worker 12/20] RUN sed -i 's/\r$//g' /start-celeryworker                                                                                                                                                              0.0s
 => CACHED [fastapi_celery_example_celery_worker 13/20] RUN chmod +x /start-celeryworker                                                                                                                                                                       0.0s
 => CACHED [fastapi_celery_example_celery_worker 14/20] COPY ./compose/local/fastapi/celery/beat/start /start-celerybeat                                                                                                                                       0.0s
 => CACHED [fastapi_celery_example_celery_worker 15/20] RUN sed -i 's/\r$//g' /start-celerybeat                                                                                                                                                                0.0s
 => CACHED [fastapi_celery_example_celery_worker 16/20] RUN chmod +x /start-celerybeat                                                                                                                                                                         0.0s
 => CACHED [fastapi_celery_example_celery_worker 17/20] COPY ./compose/local/fastapi/celery/flower/start /start-flower                                                                                                                                         0.0s
 => CACHED [fastapi_celery_example_celery_worker 18/20] RUN sed -i 's/\r$//g' /start-flower                                                                                                                                                                    0.0s
 => CACHED [fastapi_celery_example_celery_worker 19/20] RUN chmod +x /start-flower                                                                                                                                                                             0.0s
 => CACHED [fastapi_celery_example_celery_worker 20/20] WORKDIR /app                                                                                                                                                                                           0.0s
 => [fastapi_celery_example_celery_flower] exporting to image                                                                                                                                                                                                  0.0s
 => => exporting layers                                                                                                                                                                                                                                        0.0s
 => => writing image sha256:81964658771733f0def1f081ebd3ae18a9d79f89403f4ebca7f4d21a22cb3b22                                                                                                                                                                   0.0s
 => => writing image sha256:a1c308cbb9ac5221e8b2961a190f2123e9d35a633f2d4563ef93d7e0537835da                                                                                                                                                                   0.0s
 => => naming to docker.io/library/fastapi_celery_example_celery_beat                                                                                                                                                                                          0.0s
 => => writing image sha256:7408b983e9239811ea2e85c2ec545d5ad6a27f7e983d84550824e047d1ca5fa5                                                                                                                                                                   0.0s
 => => naming to docker.io/library/fastapi_celery_example_web                                                                                                                                                                                                  0.0s
 => => naming to docker.io/library/fastapi_celery_example_celery_worker                                                                                                                                                                                        0.0s
 => => writing image sha256:e3a7e9487101b2899f1d8384bdaa80245321f9d1527afedc3137d17ab36ea9e9                                                                                                                                                                   0.0s
 => => naming to docker.io/library/fastapi_celery_example_celery_flower                                                                                                                                                                                        0.0s
[+] Running 8/4
 ⠿ Network fastapi-celery-project_default            Created                                                                                                                                                                                                   0.0s
 ⠿ Volume "fastapi-celery-project_postgres_data"     Created                                                                                                                                                                                                   0.0s
 ⠿ Container fastapi-celery-project-redis-1          Created                                                                                                                                                                                                   0.2s
 ⠿ Container fastapi-celery-project-db-1             Created                                                                                                                                                                                                   0.2s
 ⠿ Container fastapi-celery-project-celery_beat-1    Created                                                                                                                                                                                                   0.0s
 ⠿ Container fastapi-celery-project-flower-1         Created                                                                                                                                                                                                   0.1s
 ⠿ Container fastapi-celery-project-celery_worker-1  Created                                                                                                                                                                                                   0.1s
 ⠿ Container fastapi-celery-project-web-1            Created                                                                                                                                                                                                   0.1s
Attaching to fastapi-celery-project-celery_beat-1, fastapi-celery-project-celery_worker-1, fastapi-celery-project-db-1, fastapi-celery-project-flower-1, fastapi-celery-project-redis-1, fastapi-celery-project-web-1
fastapi-celery-project-db-1             | The files belonging to this database system will be owned by user "postgres".
fastapi-celery-project-db-1             | This user must also own the server process.
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | The database cluster will be initialized with locale "en_US.utf8".
fastapi-celery-project-db-1             | The default database encoding has accordingly been set to "UTF8".
fastapi-celery-project-db-1             | The default text search configuration will be set to "english".
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | Data page checksums are disabled.
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | fixing permissions on existing directory /var/lib/postgresql/data ... ok
fastapi-celery-project-db-1             | creating subdirectories ... ok
fastapi-celery-project-db-1             | selecting dynamic shared memory implementation ... posix
fastapi-celery-project-db-1             | selecting default max_connections ... 100
fastapi-celery-project-redis-1          | 1:C 03 Feb 2023 15:09:53.058 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
fastapi-celery-project-redis-1          | 1:C 03 Feb 2023 15:09:53.058 # Redis version=7.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
fastapi-celery-project-redis-1          | 1:C 03 Feb 2023 15:09:53.058 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 15:09:53.059 * monotonic clock: POSIX clock_gettime
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 15:09:53.059 * Running mode=standalone, port=6379.
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 15:09:53.059 # Server initialized
fastapi-celery-project-redis-1          | 1:M 03 Feb 2023 15:09:53.062 * Ready to accept connections
fastapi-celery-project-db-1             | selecting default shared_buffers ... 128MB
fastapi-celery-project-db-1             | selecting default time zone ... UTC
fastapi-celery-project-db-1             | creating configuration files ... ok
fastapi-celery-project-db-1             | running bootstrap script ... ok
fastapi-celery-project-db-1             | sh: locale: not found
fastapi-celery-project-db-1             | 2023-02-03 15:09:53.395 UTC [30] WARNING:  no usable system locales were found
fastapi-celery-project-db-1             | performing post-bootstrap initialization ... ok
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-db-1             | initdb: warning: enabling "trust" authentication for local connections
fastapi-celery-project-db-1             | You can change this by editing pg_hba.conf or using the option -A, or
fastapi-celery-project-db-1             | --auth-local and --auth-host, the next time you run initdb.
fastapi-celery-project-db-1             | syncing data to disk ... ok
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | Success. You can now start the database server using:
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             |     pg_ctl -D /var/lib/postgresql/data -l logfile start
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | waiting for server to start....2023-02-03 15:09:53.891 UTC [36] LOG:  starting PostgreSQL 14.6 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
fastapi-celery-project-db-1             | 2023-02-03 15:09:53.892 UTC [36] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fastapi-celery-project-db-1             | 2023-02-03 15:09:53.895 UTC [37] LOG:  database system was shut down at 2023-02-03 15:09:53 UTC
fastapi-celery-project-db-1             | 2023-02-03 15:09:53.898 UTC [36] LOG:  database system is ready to accept connections
fastapi-celery-project-db-1             |  done
fastapi-celery-project-db-1             | server started
fastapi-celery-project-db-1             | CREATE DATABASE
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | waiting for server to shut down....2023-02-03 15:09:54.046 UTC [36] LOG:  received fast shutdown request
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.046 UTC [36] LOG:  aborting any active transactions
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.048 UTC [36] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.048 UTC [38] LOG:  shutting down
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.057 UTC [36] LOG:  database system is shut down
fastapi-celery-project-db-1             |  done
fastapi-celery-project-db-1             | server stopped
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | PostgreSQL init process complete; ready for start up.
fastapi-celery-project-db-1             | 
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.169 UTC [1] LOG:  starting PostgreSQL 14.6 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.169 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.169 UTC [1] LOG:  listening on IPv6 address "::", port 5432
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.170 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.173 UTC [51] LOG:  database system was shut down at 2023-02-03 15:09:54 UTC
fastapi-celery-project-db-1             | 2023-02-03 15:09:54.176 UTC [1] LOG:  database system is ready to accept connections
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-web-1            | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...
fastapi-celery-project-flower-1         | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_beat-1    | Waiting for PostgreSQL to become available...
fastapi-celery-project-celery_worker-1  | Waiting for PostgreSQL to become available...

@michael-yin
Copy link
Contributor

@webbpinner

I did some research on this issue and figured it out

Why this issue happen

On apple silicon, we got Postgresql SCRAM authentication problem? so the program hang with "Waiting for PostgreSQL to become available" message.

Solution

We can use Rosetta to make our program work with "linux/amd64" instead of the "arm64"

Below are the steps:

  1. Please remove all "docker containers" and "docker images" for a clean env. https://stackoverflow.com/questions/44785585/how-can-i-delete-all-local-docker-images
  2. Git clone the project again without modification.

And then run command below

# install rosetta
softwareupdate --install-rosetta

# tell docker to build and run on amd64 platform
export DOCKER_DEFAULT_PLATFORM=linux/amd64
docker-compose build
docker-compose up

I already tested it on real M1 Mac and it worked.

Thx

@webbpinner
Copy link
Author

I can confirm that this worked for me too. I did have to change the docker-compose.yml back to how it is in the repo. Thanks for the help.

@padrian2s
Copy link

padrian2s commented May 18, 2023

I get

Error response from daemon: image with reference django_celery_example_celery_flower was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8

@michael-yin @mjhea0

@michael-yin
Copy link
Contributor

@padrian2s

What is your OS?

Thx.

@padrian2s
Copy link

@padrian2s

What is your OS?

Thx.

Latest os with M2 from apple.

Thanks

@padrian2s
Copy link

Changed the os architecture from image line, suggested from above. Same problem? Waiting.. for sql

@michael-yin
Copy link
Contributor

@padrian2s

You need to remove your docker containers and docker images for a clean start

https://stackoverflow.com/questions/44785585/how-can-i-delete-all-local-docker-images

And then

# install rosetta
softwareupdate --install-rosetta

# tell docker to build and run on amd64 platform
export DOCKER_DEFAULT_PLATFORM=linux/amd64
docker-compose build
docker-compose up

@padrian2s
Copy link

Yes, docker system prune -a

Done that

@padrian2s
Copy link

is working on my side.

@alejandrobalderas
Copy link

alejandrobalderas commented Aug 25, 2023

A far better solution is to use psycopg2==2.9.3 instead of psycopg2-binary==2.9.3

Here is what is happening
psycopg/psycopg2#1360 (comment)

and you can see this stack overflow question which is the reason why our code was failing
https://stackoverflow.com/questions/62807717/how-can-i-solve-postgresql-scram-authentication-problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants