Ghost’s docker Mirror Mapping Port is Invalid

  docker, question

system environment

  • ubuntu 14.04 64bit
  • docker 1.6.0
  • Ghost mirror

Operation

  1. Download ghost&& Make ghost Images Yourself
  2. docker run -it -p 127.0.0.1::2368 ghost bash
  3. Npm start started ghost successfully.
  4. Another shelldocker ps -a
adolph@geek:~$ docker ps -a
 CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                       NAMES
 84802ccaa8f7        ghost:latest        "/entrypoint.sh bash   32 seconds ago      Up 31 seconds       127.0.0.1:32769->2368/tcp   kickass_bell
 adolph@geek:~$

Problem description

Enter in browserlocalhost:32769Cannot connect to resource after

I want to know what it is except the problem.

Ghost’s Dockerfile

shell#build ghost image
 FROM adolphlwq/ubuntu:14.04_64_base_image
 MAINTAINER adolphlwq  <nalan3015@126.com >
 ENV REFRESHED_AT 2015-6-9
 
 RUN apt-get update && apt-get -yqq upgrade
 
 #install node
 RUN apt-get install -yqq nodejs npm wget unzip
 RUN ln -s /usr/bin/nodejs /usr/bin/node
 
 #install ghost-zh
 RUN cd /opt/ && wget  http://dl.ghostchina.com/Ghost-0.6.3-zh-full.zip && unzip -uo Ghost-0.6.3-zh-full.zip -d ghost && rm Ghost-0.6.3-zh-full.zip
 
 #initial ghost
 RUN cd /opt/ghost && npm install --production
 
 #workdir
 WORKDIR /opt/ghost/
 
 #expose port 2368
 EXPOSE 2368
 
 CMD npm start

Then I looked at ghost’s mirror Dockerfile on the Daocloud. The core is similar. I don’t know what my problem is. Port mapping has been failing all the time.
Dockerfile for ghost on daocloud

There are under ghost file directoryconfig.example.jsThe file is used to configure relevant parameters:

config = {
 // ### Production
 // When running Ghost in the wild, use the production environment.
 // Configure your URL and mail settings here
 production: {
 ......
 },
 
 server: {
 host: '0.0.0.0',
 port: '2368'
 }
 },

The crux of the problem lies inserverThe configuration of the item. The default islocalhostIt seems that the default localhost for general hosts corresponds to 127.0.0.1 (you can also/etc/hostsRevision). Localhost is a fake ip that can only be accessed locally.0.0.0.0Wildcard-like*Can match any ip.See this answer for details..

Therefore, you should modify the configuration item of config.example.js and change the server binding address to0.0.0.0Just do it.

Finally, I also made a ghost docker image, and also used nginx to configure the agent. UsedLet’s EncryptEncryption https, you can refer to the following: