We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Run Ghost

Cool, we've got a named volume ready to go. Time to run Ghost in Docker.

Assignment

Docker hosts an official image for Ghost on Docker Hub.

  1. docker pull ghost
    
  2. docker run -d \
      -e NODE_ENV=development \
      -e url=http://localhost:3001 \
      -e database__connection__filename=/var/lib/ghost/content/data/ghost-dev.db \
      -p 3001:2368 \
      -v ghost-vol:/var/lib/ghost/content \
      ghost
    
    • -d runs the image in detached mode to avoid blocking the terminal.
    • -e NODE_ENV=development sets an environment variable within the container. This tells Ghost to run in "development" mode (rather than "production", for instance)
    • -e url=http://localhost:3001 sets another environment variable, this one tells Ghost that we want to be able to access Ghost via a URL on our host machine.
    • -e database__connection__filename=/var/lib/ghost/content/data/ghost-dev.db specifies where Ghost stores its SQLite database.
    • We've used -p before. -p 3001:2368 does some port-forwarding between the container and our host machine.
    • -v ghost-vol:/var/lib/ghost/content mounts the volume we created at Ghost's content directory, so its files, including the database, survive when we replace the container.

Run and submit the CLI tests against http://localhost:3001.