1

I'm trying to create a custom Docker image for Ghost (https://ghost.org/) with some themes pre-installed. I pulled the official image (https://hub.docker.com/_/ghost/) and installed the Uno Zen (https://github.com/Kikobeats/uno-zen) theme as per the instructions - clone into content/themes, run the setup script etc.

I then ran docker commit to push these changes as another layer on the existing Docker image. However, the next time I spin up a container using this image, I do not see the theme files where they should be. It's like none of the changes persisted.

What am I doing wrong?

fwx
  • 333
  • 1
  • 5
  • 14

1 Answers1

1

The problem is that /var/lib/ghost/content is declared as a volume:

ENV GHOST_CONTENT /var/lib/ghost/content
...
VOLUME $GHOST_CONTENT

When a directory is declared as a volume in a Dockerfile, any modifications made on it are not saved afterwards when building or committing a new image.

A possible workaround would be to copy the /var/lib/ghost/content to another, say, /var/lib/ghost/content.real and reconfigure. You may add these commands to your Dockerfile (I suggest you make your changes in a Dockerfile instead of run & commit).

 ENV GHOST_CONTENT /var/lib/ghost/content.real
 RUN cp -a /var/lib/ghost/content "$GHOST_CONTENT"; \
        gosu node ghost config --ip 0.0.0.0 --port 2368 --no-prompt --db sqlite3 --url http://localhost:2368 --dbpath "$GHOST_CONTENT/data/ghost.db"; \
        gosu node ghost config paths.contentPath "$GHOST_CONTENT"

 VOLUME "$GHOST_CONTENT"

Hints taken from the original Dockerfile:

https://github.com/docker-library/ghost/blob/a9b023e922f4f44c4c15f765973c2939f1be9b12/1/debian/Dockerfile

Ricardo Branco
  • 5,740
  • 1
  • 21
  • 31
  • well TIL. thanks for this. any suggestions as to how i can achieve what i'm looking to do? – fwx Aug 12 '17 at 18:26
  • so as per your suggestion of using a Dockerfile instead, should i make the setup procedure for the theme part of my Dockerfile as well? – fwx Aug 13 '17 at 06:17
  • Yes. You can achieve that with a combination of the `COPY` and `RUN` directives. – Ricardo Branco Aug 13 '17 at 15:05