ghost container with docker-compose

Page content

얼마전에 구성한 ghost container는 ghost가 1.x로 업데이트가 되면서 설정 정보의 위치가 변경되었는데 그걸 미처 몰라 블로그 주소가 기본값인 localhost로 설정되는 문제가 있었다. 기존 ghost container에 접근해서 확인해 보니 `/var/lib/ghost/config.production.json’ 파일에 주소가 설정되어 있는 걸 보고 이 파일도 따로 지정해 주도록 변경했다. 그러면서 docker-compose를 한번 써 보기로

일단 기존 ghost를 정리하고

cychong:~ cychong$ docker stop ghost
ghost
cychong:~ cychong$ docker rm ghost
ghost
cychong:~ cychong$ docker rmi ghost
Untagged: ghost:latest
Untagged: ghost@sha256:a1f70641d35755395eb16827de4e67861e01bffe18bac8e54ab5c68cd170a2ea
Deleted: sha256:e6ba3dd3c2491c6086d570fa9769a9f60d7c004129ff9ae7ff9fa0bad16a993b
Deleted: sha256:c1ee9d43624bb4a1922c15d7a9175a80d1952cb71464d6d9d900fe21948227af
Deleted: sha256:f8f95cdbafce4ecd226cdd690e6f909203a0f83d3507c53a71d4e59826ea881b
Deleted: sha256:935d8847555992b702173b83b0d210f2728a24b5287467396dc8d5c68907691f
Deleted: sha256:f4766b72a49d4cd2e897da0efcec94c33a0d24a95cb8426a790e1c45e6e39fae
Deleted: sha256:0c0dbaebe17c6f585eb596e705ed5acba668097698a7780844c12597bb99b34a
Deleted: sha256:c807796bea7a34c0b73eae853b728f2bbcd7a4fecc19d049455b322120f95ce7
Deleted: sha256:15f9f4e44e22d3287b6caf9555110383d3ff2e88ee9cc03823b1ba5a01b75eac
Deleted: sha256:77809f11069f2abfb571cba07ee3d696ec32823df0f5d0587042ffdb27a80add
Deleted: sha256:5d6bba18f7b25c9b93d3cc0d93a4cff54eb88b0ba22ed867633a21fc3ded5f57

하는 김에 최신 버전의 ghost받아오고

cychong:~ cychong$ docker pull ghost
Using default tag: latest
latest: Pulling from library/ghost
ad74af05f5a2: Already exists 
2b032b8bbe8b: Pull complete 
ad85906adb69: Pull complete 
3caae50f774b: Pull complete 
ef87a0ce8025: Pull complete 
fc62209fe861: Pull complete 
8610d8088e2a: Pull complete 
c360787a43d4: Pull complete 
5d4f585a7cb1: Pull complete 
e204e870e4fc: Pull complete 
Digest: sha256:6c1adf02635cf2a31479a436192068f60c3cc86242d21093f55783ab1d1dd107
Status: Downloaded newer image for ghost:latest

docker history 명령을 보니 ghost 버전이 1.8.1로 바뀐 걸 알 수 있네.(좀 쉽게 알 수는 없을까?)

cychong:~ cychong$ docker history ghost
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
2d71383c27b9        2 days ago          /bin/sh -c #(nop)  CMD ["node" "current/in...   0B                  
<missing>           2 days ago          /bin/sh -c #(nop)  EXPOSE 2368/tcp              0B                  
<missing>           2 days ago          /bin/sh -c #(nop)  ENTRYPOINT ["docker-ent...   0B                  
<missing>           2 days ago          /bin/sh -c #(nop) COPY file:ef6da72f41bc8f...   646B                
<missing>           2 days ago          /bin/sh -c #(nop)  VOLUME [/var/lib/ghost/...   0B                  
<missing>           2 days ago          /bin/sh -c #(nop) WORKDIR /var/lib/ghost        0B                  
<missing>           2 days ago          /bin/sh -c set -ex;  mkdir -p "$GHOST_INST...   289MB               
<missing>           2 days ago          /bin/sh -c #(nop)  ENV GHOST_CONTENT=/var/...   0B                  
<missing>           2 days ago          /bin/sh -c #(nop)  ENV GHOST_INSTALL=/var/...   0B                  
<missing>           2 days ago          /bin/sh -c npm install -g "ghost-cli@$GHOS...   143MB               
<missing>           2 days ago          /bin/sh -c #(nop)  ENV GHOST_VERSION=1.8.1      0B                  
<missing>           8 days ago          /bin/sh -c #(nop)  ENV GHOST_CLI_VERSION=1...   0B                  
<missing>           8 days ago          /bin/sh -c #(nop)  ENV NODE_ENV=production      0B                  
<missing>           8 days ago          /bin/sh -c #(nop)  ENV NPM_CONFIG_LOGLEVEL...   0B                  
<missing>           8 days ago          /bin/sh -c set -x  && wget -O /usr/local/b...   1.29MB              
<missing>           8 days ago          /bin/sh -c #(nop)  ENV GOSU_VERSION=1.10        0B                  
<missing>           2 weeks ago         /bin/sh -c #(nop)  CMD ["node"]                 0B                  
<missing>           2 weeks ago         /bin/sh -c set -ex   && for key in     6A0...   3.89MB              
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV YARN_VERSION=0.27.5      0B                  
<missing>           2 weeks ago         /bin/sh -c buildDeps='xz-utils'     && ARC...   42.5MB              
<missing>           4 weeks ago         /bin/sh -c #(nop)  ENV NODE_VERSION=6.11.2      0B                  
<missing>           5 weeks ago         /bin/sh -c #(nop)  ENV NPM_CONFIG_LOGLEVEL...   0B                  
<missing>           5 weeks ago         /bin/sh -c set -ex   && for key in     955...   131kB               
<missing>           5 weeks ago         /bin/sh -c groupadd --gid 1000 node   && u...   335kB               
<missing>           5 weeks ago         /bin/sh -c set -ex;  if ! command -v gpg >...   0B                  
<missing>           5 weeks ago         /bin/sh -c apt-get update && apt-get insta...   44.6MB              
<missing>           5 weeks ago         /bin/sh -c #(nop)  CMD ["bash"]                 0B                  
<missing>           5 weeks ago         /bin/sh -c #(nop) ADD file:a023a99f7d01868...   123MB   

my-ghost/docker-compose.yaml

version: '3'

services:
   ghost:
     container_name: ghost
     image: ghost:latest
     volumes:
       - /Users/cychong/Dropbox/Apps/ghost/content/:/var/lib/ghost/content   
       - /Users/cychong/Dropbox/Apps/ghost/config.production.json:/var/lib/ghost/config.production.json
     ports:
       - "2368:2368"
     restart: always
     environment:
       - NODE_ENV=production
volumes:
    db_data:

go!

cychong:~/work/my_ghost cychong$ docker-compose up -d
Creating network "myghost_default" with the default driver
Creating volume "myghost_db_data" with default driver
Creating ghost ... 
Creating ghost ... done

어디 볼까?

cychong:~/work/my_ghost cychong$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
dea965b550e6        ghost:latest        "docker-entrypoint..."   17 seconds ago      Up 16 seconds       0.0.0.0:2368->2368/tcp   ghost

잠시 후 웹브라우저로 확인해 보면 제대로 접속은 되는데 의도한 대로 주소가 localhost가 아니라 sosa0sa.com으로 되었는지는 이 글을 publish하면 알 수 있겠지.