Cant run service with docker-compose.yml file #136

Closed
opened 2020-02-15 09:09:45 +00:00 by Arthurle · 2 comments

I am using the yml file from: https://vikunja.io/docs/full-docker-example/
under "Example with nginx as proxy" and followed the instructions.
The Problem is that the api tries to connect to the database before it is up.

My docker-compose.yml

version: '3'

services:
  db:
    image: mariadb:10
    environment:
      MYSQL_ROOT_PASSWORD: supersecret
      MYSQL_DATABASE: vikunja
    volumes:
      - ./db:/var/lib/mysql
  frontend:
    image: vikunja/frontend
  api:
    image: vikunja/api
    environment:
      VIKUNJA_DATABASE_HOST: db
      VIKUNJA_DATABASE_PASSWORD: supersecret
      VIKUNJA_DATABASE_TYPE: mysql
      VIKUNJA_DATABASE_USER: root
      VIKUNJA_DATABASE_DATABASE: vikunja
    volumes:
      - ./files:/app/vikunja/files
    depends_on:
      - db
  proxy:
    image: nginx
    ports:
      - 80:80
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - api
      - frontend

I run docker-compose up to start the containers

My Error:

root@h2867610:~/test# docker-compose up
Starting test_frontend_1 ... done
Starting test_db_1       ... done
Starting test_api_1      ... done
Starting test_proxy_1    ... done
Attaching to test_frontend_1, test_db_1, test_api_1, test_proxy_1
api_1       | 2020/02/15 09:00:57 Config File "config" Not Found in "[/app/vikunja /etc/vikunja /app/vikunja/~/.config/vikunja]"
api_1       | 2020/02/15 09:00:57 Using defaults.
api_1       | 2020-02-15T09:00:57.762789668Z: CRITICAL  ▶ migration/Migrate 001 Migration failed: dial tcp 172.22.0.3:3306: connect: connection refused
api_1       | Migration failed: dial tcp 172.22.0.3:3306: connect: connection refused
db_1        | 2020-02-15 09:00:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
db_1        | 2020-02-15 09:00:56+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db_1        | 2020-02-15 09:00:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started.
db_1        | 2020-02-15  9:00:57 0 [Note] mysqld (mysqld 10.4.12-MariaDB-1:10.4.12+maria~bionic) starting as process 1 ...
test_api_1 exited with code 1
db_1        | 2020-02-15  9:00:57 0 [Note] InnoDB: Using Linux native AIO
db_1        | 2020-02-15  9:00:57 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
db_1        | 2020-02-15  9:00:57 0 [Note] InnoDB: Uses event mutexes
db_1        | 2020-02-15  9:00:57 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
db_1        | 2020-02-15  9:00:57 0 [Note] InnoDB: Number of pools: 1
db_1        | 2020-02-15  9:00:57 0 [Note] InnoDB: Using SSE2 crc32 instructions
db_1        | 2020-02-15  9:00:57 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Completed initialization of buffer pool
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: 128 out of 128 rollback segments are active.
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Creating shared tablespace for temporary tables
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Waiting for purge to start
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: 10.4.12 started; log sequence number 362601; transaction id 798
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
db_1        | 2020-02-15  9:00:58 0 [Note] Plugin 'FEEDBACK' is disabled.
db_1        | 2020-02-15  9:00:58 0 [Note] InnoDB: Buffer pool(s) load completed at 200215  9:00:58
db_1        | 2020-02-15  9:00:58 0 [Note] Server socket created on IP: '::'.
db_1        | 2020-02-15  9:00:58 0 [Warning] 'proxies_priv' entry '@% root@b37a043804a7' ignored in --skip-name-resolve mode.
db_1        | 2020-02-15  9:00:58 0 [Note] Reading of all Master_info entries succeeded
db_1        | 2020-02-15  9:00:58 0 [Note] Added new Master_info '' to hash table
db_1        | 2020-02-15  9:00:58 0 [Note] mysqld: ready for connections.
db_1        | Version: '10.4.12-MariaDB-1:10.4.12+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
proxy_1     | 2020/02/15 09:00:59 [emerg] 1#1: host not found in upstream "api" in /etc/nginx/conf.d/default.conf:9
proxy_1     | nginx: [emerg] host not found in upstream "api" in /etc/nginx/conf.d/default.conf:9
test_proxy_1 exited with code 1

I am using the yml file from: https://vikunja.io/docs/full-docker-example/ under "Example with nginx as proxy" and followed the instructions. The Problem is that the api tries to connect to the database before it is up. My docker-compose.yml ``` version: '3' services: db: image: mariadb:10 environment: MYSQL_ROOT_PASSWORD: supersecret MYSQL_DATABASE: vikunja volumes: - ./db:/var/lib/mysql frontend: image: vikunja/frontend api: image: vikunja/api environment: VIKUNJA_DATABASE_HOST: db VIKUNJA_DATABASE_PASSWORD: supersecret VIKUNJA_DATABASE_TYPE: mysql VIKUNJA_DATABASE_USER: root VIKUNJA_DATABASE_DATABASE: vikunja volumes: - ./files:/app/vikunja/files depends_on: - db proxy: image: nginx ports: - 80:80 volumes: - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro depends_on: - api - frontend ``` I run docker-compose up to start the containers My Error: ``` root@h2867610:~/test# docker-compose up Starting test_frontend_1 ... done Starting test_db_1 ... done Starting test_api_1 ... done Starting test_proxy_1 ... done Attaching to test_frontend_1, test_db_1, test_api_1, test_proxy_1 api_1 | 2020/02/15 09:00:57 Config File "config" Not Found in "[/app/vikunja /etc/vikunja /app/vikunja/~/.config/vikunja]" api_1 | 2020/02/15 09:00:57 Using defaults. api_1 | 2020-02-15T09:00:57.762789668Z: CRITICAL ▶ migration/Migrate 001 Migration failed: dial tcp 172.22.0.3:3306: connect: connection refused api_1 | Migration failed: dial tcp 172.22.0.3:3306: connect: connection refused db_1 | 2020-02-15 09:00:56+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started. db_1 | 2020-02-15 09:00:56+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2020-02-15 09:00:57+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.4.12+maria~bionic started. db_1 | 2020-02-15 9:00:57 0 [Note] mysqld (mysqld 10.4.12-MariaDB-1:10.4.12+maria~bionic) starting as process 1 ... test_api_1 exited with code 1 db_1 | 2020-02-15 9:00:57 0 [Note] InnoDB: Using Linux native AIO db_1 | 2020-02-15 9:00:57 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins db_1 | 2020-02-15 9:00:57 0 [Note] InnoDB: Uses event mutexes db_1 | 2020-02-15 9:00:57 0 [Note] InnoDB: Compressed tables use zlib 1.2.11 db_1 | 2020-02-15 9:00:57 0 [Note] InnoDB: Number of pools: 1 db_1 | 2020-02-15 9:00:57 0 [Note] InnoDB: Using SSE2 crc32 instructions db_1 | 2020-02-15 9:00:57 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts) db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Completed initialization of buffer pool db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: 128 out of 128 rollback segments are active. db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Creating shared tablespace for temporary tables db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Waiting for purge to start db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: 10.4.12 started; log sequence number 362601; transaction id 798 db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool db_1 | 2020-02-15 9:00:58 0 [Note] Plugin 'FEEDBACK' is disabled. db_1 | 2020-02-15 9:00:58 0 [Note] InnoDB: Buffer pool(s) load completed at 200215 9:00:58 db_1 | 2020-02-15 9:00:58 0 [Note] Server socket created on IP: '::'. db_1 | 2020-02-15 9:00:58 0 [Warning] 'proxies_priv' entry '@% root@b37a043804a7' ignored in --skip-name-resolve mode. db_1 | 2020-02-15 9:00:58 0 [Note] Reading of all Master_info entries succeeded db_1 | 2020-02-15 9:00:58 0 [Note] Added new Master_info '' to hash table db_1 | 2020-02-15 9:00:58 0 [Note] mysqld: ready for connections. db_1 | Version: '10.4.12-MariaDB-1:10.4.12+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution proxy_1 | 2020/02/15 09:00:59 [emerg] 1#1: host not found in upstream "api" in /etc/nginx/conf.d/default.conf:9 proxy_1 | nginx: [emerg] host not found in upstream "api" in /etc/nginx/conf.d/default.conf:9 test_proxy_1 exited with code 1 ```
Owner

This seems to be kind of related to how docker compose handles scheduling the startup etc.

Until we put a better timeout configuration in Vikunja itself, try adding a restart: unless-stopped to the api service in your config.

This seems to be kind of related to how docker compose handles scheduling the startup etc. Until we put a better timeout configuration in Vikunja itself, try adding a `restart: unless-stopped` to the api service in your config.
Owner

Closing this due to inactivity - feel free to repoen.

Closing this due to inactivity - feel free to repoen.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
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: vikunja/vikunja#136
No description provided.