docker run -it -p 127.0.0.1::2368 ghost bash
docker 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:~$
在浏览器输入localhost:32769
后无法连接到资源
想知道到底是哪里除了问题?
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
然后我又看了Daocloud上ghost的镜像Dockerfile,核心的地方是类似的,不知道我的问题出在哪,端口映射一直失败
daocloud上ghost的Dockerfile
There is a
file in the
config.example.js
ghost file directory to configure related parameters:The core of the problem lies in the configuration of the server item. The default is
localhost
好像,一般主机默认的localhost是和127.0.0.1对应的(你也可以在/etc/hosts
修改)。localhost是一个伪造的ip,只能本机访问。0.0.0.0
类似通配符*
, which can match any IP. See this answer for details.So you should modify the configuration items of config.example.js and change the address bound to the server to
0.0.0.0
.Finally, I also made a ghost docker image, and also used the proxy configured by nginx. Let's Encrypt is used to encrypt https, you can refer to the following:
Docker image:qBlog
my blog
No one answered. I also encountered the same problem. The nginx image I made myself also has an EXPOSE port in the Dockerfile. When running the image, even if the -p parameter is not used, the image service can be accessed through the IP of the host. , and none of them take effect when the -p parameter is specified to open port mapping. Mark it, I’ll look for the answer first