1

Here is the docker file i made

version: '3.1'

services:
 ghost:
      image: ghost:latest
      container_name: ghost
      restart: always
      ports:
      - 2368:2368
      environment:
      # see https://docs.ghost.org/docs/config#section-running-ghost-with-config-env-variables
        database__client: mysql
        database__connection__host: db
        database__connection__user: ghost
        database__connection__password: password
        database__connection__database: ghost
        GHOST_HOST: sub.techie.today
        VIRTUAL_HOST: sub.techie.today
        LETSENCRYPT_HOST: sub.techie.today
        LETSENCRYPT_EMAIL: web@sub.techie.today
      depends_on:
      - ghostdb

 ghostdb:
      image: mariadb:latest
      container_name: ghostdb
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: password
        MYSQL_USER: ghost
        MYSQL_PASSWORD: password
        MYSQL_DATABASE: ghost

networks:
    default:
       external:
         name: webproxy

Am trying to create with docker but whenever i do that deploying everything okay but its not working . when i debug docker i can see mysql is not connecting to ghost docker ."docker logs --tail 50 --follow --timestamps ghost" output is

2019-02-23T07:38:05.127234468Z NAME: DatabaseError
2019-02-23T07:38:05.127253008Z CODE: ENOTFOUND
2019-02-23T07:38:05.127258325Z MESSAGE: Invalid database host.
2019-02-23T07:38:05.127262748Z 
2019-02-23T07:38:05.127266883Z level:normal
2019-02-23T07:38:05.127271270Z 
2019-02-23T07:38:05.127275440Z "Please double check your database config."
2019-02-23T07:38:05.127279900Z DatabaseError: Invalid database host.
2019-02-23T07:38:05.127284257Z     at DatabaseError.KnexMigrateError (/var/lib/ghost/versions/2.15.0/node_modules/knex-migrator/lib/errors.js:7:26)
2019-02-23T07:38:05.127289754Z     at new DatabaseError (/var/lib/ghost/versions/2.15.0/node_modules/knex-migrator/lib/errors.js:56:26)
2019-02-23T07:38:05.127296828Z     at connection.raw.catch (/var/lib/ghost/versions/2.15.0/node_modules/knex-migrator/lib/database.js:33:23)
2019-02-23T07:38:05.127301045Z     at tryCatcher (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/util.js:16:23)
2019-02-23T07:38:05.127305373Z     at Promise._settlePromiseFromHandler (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/promise.js:512:31)
2019-02-23T07:38:05.127309660Z     at Promise._settlePromise (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/promise.js:569:18)
2019-02-23T07:38:05.127313973Z     at Promise._settlePromise0 (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/promise.js:614:10)
2019-02-23T07:38:05.127318430Z     at Promise._settlePromises (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/promise.js:690:18)
2019-02-23T07:38:05.127334535Z     at _drainQueueStep (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/async.js:138:12)
2019-02-23T07:38:05.127338612Z     at _drainQueue (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/async.js:131:9)
2019-02-23T07:38:05.127342467Z     at Async._drainQueues (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/async.js:147:5)
2019-02-23T07:38:05.127346359Z     at Immediate.Async.drainQueues (/var/lib/ghost/versions/2.15.0/node_modules/bluebird/js/release/async.js:17:14)

How to make it possible with docker file ? anyone please help me ?

  • Welcome to stackoverflow. The question is related to docker and not JS. Use proper tags so the question comes to light in front of right people to help you. – Sagar Agrawal Feb 23 '19 at 08:13

1 Answers1

0

Your database address is not db. Use ghostdb instead:

database__connection__host: ghostdb

Also, you still be able to use deprecated links feature. Works for me. I use docker-compose version 1.22.0.

links:
   - ghostdb:db

ghost still spray errors on start. Because take time mariadb to start. You can use some of the suggestions in this post to avoid ghost start before mariadb is ready. Or create some healthcheck command.

After pause and mariadb is ready to use you see log:

ghost      | [2019-02-23 11:08:52] INFO Creating table: posts 
ghost      | [2019-02-23 11:08:52] INFO Creating table: users 
ghost      | [2019-02-23 11:08:53] INFO Creating table: posts_authors 
ghost      | [2019-02-23 11:08:53] INFO Creating table: roles 
ghost      | [2019-02-23 11:08:53] INFO Creating table: roles_users 
ghost      | [2019-02-23 11:08:53] INFO Creating table: permissions 
ghost      | [2019-02-23 11:08:54] INFO Creating table: permissions_users 
ghost      | [2019-02-23 11:08:54] INFO Creating table: permissions_roles 
ghost      | [2019-02-23 11:08:54] INFO Creating table: permissions_apps 
ghost      | [2019-02-23 11:08:54] INFO Creating table: settings 
ghost      | [2019-02-23 11:08:54] INFO Creating table: tags 
ghost      | [2019-02-23 11:08:55] INFO Creating table: posts_tags 
ghost      | [2019-02-23 11:08:55] INFO Creating table: apps 
ghost      | [2019-02-23 11:08:55] INFO Creating table: app_settings 
ghost      | [2019-02-23 11:08:56] INFO Creating table: app_fields 
ghost      | [2019-02-23 11:08:56] INFO Creating table: clients 
ghost      | [2019-02-23 11:08:56] INFO Creating table: client_trusted_domains 
ghost      | [2019-02-23 11:08:56] INFO Creating table: accesstokens 
ghost      | [2019-02-23 11:08:57] INFO Creating table: refreshtokens 
ghost      | [2019-02-23 11:08:58] INFO Creating table: subscribers 
ghost      | [2019-02-23 11:08:58] INFO Creating table: invites 
ghost      | [2019-02-23 11:08:58] INFO Creating table: brute 
ghost      | [2019-02-23 11:08:58] INFO Creating table: webhooks 
ghost      | [2019-02-23 11:08:58] INFO Creating table: sessions 
ghost      | [2019-02-23 11:08:58] INFO Creating table: integrations 
ghost      | [2019-02-23 11:08:59] INFO Creating table: api_keys 
ghost      | [2019-02-23 11:08:59] INFO Creating table: mobiledoc_revisions 
ghost      | [2019-02-23 11:08:59] INFO Creating table: members 
ghost      | [2019-02-23 11:08:59] INFO Creating table: actions 
ghost      | [2019-02-23 11:08:59] INFO Model: Tag 
ghost      | [2019-02-23 11:08:59] INFO Model: Client 
ghost      | [2019-02-23 11:08:59] INFO Model: Role 
ghost      | [2019-02-23 11:08:59] INFO Model: Permission 
ghost      | [2019-02-23 11:09:00] INFO Model: User 
ghost      | [2019-02-23 11:09:01] INFO Model: Post 
ghost      | [2019-02-23 11:09:01] INFO Model: Integration 
ghost      | [2019-02-23 11:09:01] INFO Relation: Role to Permission 
ghost      | [2019-02-23 11:09:01] INFO Relation: Post to Tag 
ghost      | [2019-02-23 11:09:01] INFO Relation: User to Role 
ghost      | [2019-02-23 11:09:02] WARN Theme's file locales/en.json not found. 
ghost      | [2019-02-23 11:09:03] INFO Ghost is running in production... 
ghost      | [2019-02-23 11:09:03] INFO Your blog is now available on http://localhost:2368/ 
ghost      | [2019-02-23 11:09:03] INFO Ctrl+C to shut down 
ghost      | [2019-02-23 11:09:03] INFO Ghost boot 11.672s 

Usually on my machine it's take 20-30 seconds

ozlevka
  • 1,988
  • 16
  • 28