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

update ghost from 1.x to 2.x in docker #147

Closed
cnjack opened this Issue Aug 27, 2018 · 21 comments

Comments

Projects
None yet
10 participants
@cnjack
Copy link

cnjack commented Aug 27, 2018

docker exec -it blog bash
su node -c "ghost update"

bring me some error

Running sudo command: systemctl is-active ghost_undefined
A ProcessError occurred.

Message: Command failed: /bin/sh -c sudo -S -p '#node-sudo-passwd#'  systemctl is-active ghost_undefined
/bin/sh: 1: sudo: not found


Exit code: 127


Debug Information:
    OS: linux, v4.16.0-999-generic
    Node Version: v8.11.4
    Ghost-CLI Version: 1.9.1
    Environment: production
    Command: 'ghost update'

Additional log info available in: /home/node/.ghost/logs/ghost-cli-debug-2018-08-27T06_40_43_725Z.log

Try running ghost doctor to check your system for known issues.

Please refer to https://docs.ghost.org/v1/docs/troubleshooting#section-cli-errors for troubleshooting.
@cnjack

This comment has been minimized.

Copy link
Author

cnjack commented Aug 27, 2018

try

docker exec -u node blog ghost update

is not ok

@cnjack

This comment has been minimized.

Copy link
Author

cnjack commented Aug 27, 2018

I try to mv sudo to the docker, it is ok
but new error:

- Checking for Ghost-CLI updates
Running sudo command: systemctl is-active ghost_undefined
/usr/local/lib/node_modules/ghost-cli/lib/ui/index.js:132
            throw new errors.SystemError('Prompts have been disabled, please provide options via command line flags');
            ^

Error: Prompts have been disabled, please provide options via command line flags
    at UI.prompt (/usr/local/lib/node_modules/ghost-cli/lib/ui/index.js:132:19)
    at Socket.cp.stderr.on (/usr/local/lib/node_modules/ghost-cli/lib/ui/index.js:212:22)
    at emitOne (events.js:121:20)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:597:20)

@wglambert wglambert added the question label Aug 27, 2018

@tianon

This comment has been minimized.

Copy link
Member

tianon commented Aug 27, 2018

You should be able to update by simply mounting your old 1.0-based volume on a Ghost 2.0 image (and it should auto-upgrade on first run). It would probably be prudent for us to add a note about this to the docs.

cc @acburdine (I might be mistaken!)

@crespum

This comment has been minimized.

Copy link

crespum commented Aug 28, 2018

That doesn't work. I don't have the detailed logs here, but it turns out the migration is not happening and the server won't start because the DB is missing the new comment_id field.

@acburdine

This comment has been minimized.

Copy link
Collaborator

acburdine commented Aug 28, 2018

Hmm...it should work the way @tianon described, but I'll do some testing and check.

@acburdine

This comment has been minimized.

Copy link
Collaborator

acburdine commented Aug 28, 2018

@crespum I checked locally and can't reproduce - the ghost v2 image migrates and starts fine when a ghost v1 content folder (using sqlite3 as the db) is mounted into it.

@crespum

This comment has been minimized.

Copy link

crespum commented Aug 29, 2018

That's strange, I've gathered the logs I get (first I pull v2 image, then I stop and remove v1 container and finally I run v2):

root@debian:~# docker pull ghost
root@debian:~# docker stop ghost-blog
ghost-blog
root@debian:~# docker rm ghost-blog
ghost-blog
root@debian:~# docker run --restart always --name ghost-blog -d -p 6001:2368 -v /home/ghost/ghost-blog:/var/lib/ghost/content ghost
891cc5e9194de27...9cab5087970
root@debian:~# docker logs ghost-blog
[2018-08-29 07:13:12] WARN Theme's file locales/en.json not found. 
[2018-08-29 07:13:13] INFO Blog is in maintenance mode. 
[2018-08-29 07:13:13] INFO Ghost is running in production... 
[2018-08-29 07:13:13] INFO Your blog is now available
[2018-08-29 07:13:13] INFO Ctrl+C to shut down 
[2018-08-29 07:13:13] INFO Ghost boot 4.071s 
[2018-08-29 07:13:13] INFO Creating database backup 
[2018-08-29 07:13:16] INFO Database backup written to: /var/lib/ghost/content/data/blog.ghost.2018-08-29.json 
[2018-08-29 07:13:16] INFO Adding demo post. 
[2018-08-29 07:13:17] INFO Rollback: Fixture posts. 
[2018-08-29 07:13:17] INFO Rollback: Bring back demo post. 
[2018-08-29 07:13:18] ERROR

NAME: RollbackError
CODE: SQLITE_ERROR
MESSAGE: insert into `posts` (`author_id`, `comment_id`, `created_at`, `created_by`, `feature_image`, `featured`, `html`, `id`, `meta_description`, `meta_title`, `mobiledoc`, `page`, `plaintext`, `published_by`, `slug`, `status`, `title`, `updated_at`, `updated_by`, `uuid`, `visibility`) values ('5951f5fca366002ebd5dbef7', '5b86478dcd8f550001a2da47', '2018-08-29 07:13:17', 1, NULL, false, 'Content of demo post', NULL, 'v2-demo-post', 'draft', 'Koenig Demo Post', '2018-08-29 07:13:17', 1, 'c7f6f55d-d619-436a-8e4c-a874bbc67552', 'public') - SQLITE_ERROR: table posts has no column named comment_id

level:normal

OuterError: insert into `posts` (`author_id`, `comment_id`, `created_at`, `created_by`, `custom_excerpt`, `feature_image`, `featured`, `html`, `id`, `meta_description`, `meta_title`, `mobiledoc`, `page`, `plaintext`, `published_at`, `published_by`, `slug`, `status`, `title`, `updated_at`, `updated_by`, `uuid`, `visibility`) values ('1', '5b86478ccd8f550001a2da46', '2018-08-29 07:13:16', 1, 'Content of demo post', NULL, 'v2-demo-post', 'draft', 'Koenig Demo Post', '2018-08-29 07:13:17', 1, 'c7f6f55d-d619-436a-8e4c-a874bbc67552', 'public') - SQLITE_ERROR: table posts has no column named comment_id
    at RollbackError.KnexMigrateError (/var/lib/ghost/versions/2.0.3/node_modules/knex-migrator/lib/errors.js:7:26)
    at new RollbackError (/var/lib/ghost/versions/2.0.3/node_modules/knex-migrator/lib/errors.js:32:26)
    at /var/lib/ghost/versions/2.0.3/node_modules/knex-migrator/lib/index.js:496:23
    at tryCatcher (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)

Error: SQLITE_ERROR: table posts has no column named comment_id
@cnjack

This comment has been minimized.

Copy link
Author

cnjack commented Aug 29, 2018

is done!

  1. backup the data dir
  2. docker rm -f blog
  3. docker run -d --name blog -v ~/data/blog:/var/lib/ghost/content -p2368:2368 ghost:1.25
  4. wait the ghost is run...
  5. docker rm -f blog
  6. docker run -d --name blog -v ~/data/blog:/var/lib/ghost/content -p2368:2368 ghost

@cnjack cnjack closed this Aug 29, 2018

@crespum

This comment has been minimized.

Copy link

crespum commented Aug 29, 2018

That's works. I don't really know what my problem was. I was using v1 before, but the docker image seems to be quite different (250MB smaller)...

~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ghost               1.25                bcd04969a22b        6 days ago          820MB
ghost               latest              1029fdadd2aa        6 days ago          827MB
ghost               <none>              b5529c7678ac        7 months ago        584MB
@BirkhoffLee

This comment has been minimized.

Copy link

BirkhoffLee commented Aug 30, 2018

I too have the same issue as @crespum. I'm using docker-compose to deploy the stack, but when I re-pull the ghost image (to get a 2.0 image) and re-deploy the stack, bunches of Error: ER_BAD_FIELD_ERROR: Unknown column 'comment_id' in 'field list' pops up. Ghost is seemly not migrating the old data and database.

@cnjack

This comment has been minimized.

Copy link
Author

cnjack commented Aug 30, 2018

@BirkhoffLee you can Imitate my operation

@BirkhoffLee

This comment has been minimized.

Copy link

BirkhoffLee commented Aug 30, 2018

@cnjack It didn't work in the first time, I tried it again and it magically worked :) thanks!

@PhilWhitehurst

This comment has been minimized.

Copy link

PhilWhitehurst commented Aug 30, 2018

I too just got this issue.

Head over to the Ghost 2.0 Theme Compatibility
[https://forum.ghost.org/t/ghost-2-0-theme-compatibility-help-support/2103]
forum topic to discuss any changes and get help if needed.

That''s it!

We''re looking forward to sharing more about the new editor soon', NULL, 'v2-demo-post', 'draft', 'Koenig Demo Post', '2018-08-30 12:59:24', 1, 'd25e8546-dacd-4352-af3d-cfb39ed8b4f0', 'public') - SQLITE_ERROR: table posts has no column named comment_id
at RollbackError.KnexMigrateError (/var/lib/ghost/versions/2.0.3/node_modules/knex-migrator/lib/errors.js:7:26)
at new RollbackError (/var/lib/ghost/versions/2.0.3/node_modules/knex-migrator/lib/errors.js:32:26)
at /var/lib/ghost/versions/2.0.3/node_modules/knex-migrator/lib/index.js:496:23
at tryCatcher (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/var/lib/ghost/versions/2.0.3/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)

Error: SQLITE_ERROR: table posts has no column named comment_id

I overcame the issue by

  1. Export content under labs menu option in admin panel
  2. Stopped ghost-:1-alpine
  3. Deleted ghost.db under data
  4. Started ghost:alpine (version 2 of ghost) pointing at same volumes as ghost:1-alpine was
  5. Went into ghost in browser and setup admin account
  6. Import previously exported content
  7. Unpublished all the gettng started ghost posts.
  8. Flushed any caches (nginx, Cloudflare between ghost on browser)
@acburdine

This comment has been minimized.

Copy link
Collaborator

acburdine commented Aug 30, 2018

@PhilWhitehurst Did you by chance try to update to 2.x from a 1.x release < 1.25.4? In Ghost-CLI we added a provision that prevented updates if you were not already running the latest 1.x version of Ghost, and my guess is that the errors you're seeing are related to the fact that you need to upgrade to the latest 1.x version first before trying the 2.x upgrade.

@tianon would it be worth adding a section to the readme noting the above? (I can draft a PR) Since a couple people have run into it already i'd imagine more people might stumble across this.

@tianon

This comment has been minimized.

Copy link
Member

tianon commented Aug 30, 2018

@PhilWhitehurst

This comment has been minimized.

Copy link

PhilWhitehurst commented Aug 30, 2018

@acburdine @tianon

Yes the version I was upgrading from was 1.22.7. It had been running in a docker container for 3 months without fail and I had not updated the image to the latest 1.x series.

Loving the new 2.0 editor by the way, very nice implementation of mobileDoc.

@hyperknot

This comment has been minimized.

Copy link

hyperknot commented Sep 1, 2018

I can confirm that direct update to2-alpine didn't work, but doing an 1-alpine before fixed it.

@AlbertoFdzM

This comment has been minimized.

Copy link

AlbertoFdzM commented Sep 21, 2018

For me the correct formula was:
From a ghost:1-alpine

  1. ghost:1
  2. ghost:2
  3. ghost:2-alpine
@acburdine

This comment has been minimized.

Copy link
Collaborator

acburdine commented Sep 28, 2018

@AlbertoFdzM the reason that process worked is not because you switched from alpine to non-alpine necessarily, but because you start Ghost again with the latest version of v1, which ran the necessary database migrations needed to then migrate to v2.

@AlbertoFdzM

This comment has been minimized.

Copy link

AlbertoFdzM commented Sep 28, 2018

@acburdine I tried several times:

  1. ghost:1-alpine
  2. ghost:2-alpine

With no results until switching to :1. Probably I was having some issues cleaning my docker cache.

@sigstart

This comment has been minimized.

Copy link

sigstart commented Nov 4, 2018

Thanks to everyone who helped troubleshoot this. It helped me too.

Something to watch out for if you're using docker-compose is if you've used just ghost or ghost:alpine for the image.

Simplest work-around for me was to just use ghost:1-alpine to upgrade to the latest version of 1.x, docker-compose up, docker-compose down, then switch to ghost:2-alpine and docker-compose up again. (You could use docker-compose pull, but I wanted to update all the images I use one at a time and avoid possible mistakes.)

After all that, you can switch back to using ghost:alpine for the image in your docker-compose file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment