I have pulled a Docker image:

$ docker pull ghost

And run a container from the image:

$ docker run --name test-ghost -p 8080:2368 -d ghost

My understanding is that the -p switch will map a port on the host (8080) to a port inside Docker (2368), so that I can hit the web server running within Docker, from outside docker, i.e. from my host.

However, when I try to browse to any of the following addresses in Chrome, from my host:


I get the following error:

This webpage is not available


This seems like it might be a connectivity issue, rather than a problem inside the container, as when I inspect the running processes inside the container, it appears that NodeJS is running:

$ docker top test-ghost
UID          PID           PPID      ...  CMD
docker       4290          1028      ...  npm
docker       4324          4290      ...  sh -c node index
docker       4325          4324      ...  node index

But it appears nothing is listening on port 8080:

$ sudo lsof -n -i4TCP:8080 | grep LISTEN

I also checked and my MacOS firewall is turned off.

I don't expect a full solution here, as I'm aware the information I've given is minimal.

What I'm wondering is, how would one go about fixing such a problem?

It seems that the Docker port is unaccessible.

Is there some way of finding out why the port mapping didn't work? Or what ports are being exposed by Docker? Perhaps I'm mapping the wrong internal port?

Or are there any other general suggestions as to what I might be doing wrong here?


Finally figured out how to make this work!

I'm running Docker on MacOS and using 'Docker QuickStart Terminal'.

Turns out, navigating to 'localhost', '', etc. was wrong, because it looks like Docker sets up its own host:

                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/

docker is configured to use the default machine with IP
For help getting started, check out the docs at https://docs.docker.com

When I use, given above, everything works fine.


To find out the IP address of the running container, you can use:

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' myContainerID

If you run docker with docker-machine use the following command to get the IP address (assuming default is your name):

docker-machine ip default

See: https://docs.docker.com/machine/reference/ip/


Started playing with docker and this is the first problem/issue I came across.

Seems like docker lets you specify if you are using ports in different modes such as - host, bridge (default)

In the bridge mode docker shows you a message once you deploy ghost - Your blog is now available on http://localhost:2368/ but visiting this url shows connection refused.

to fix this you need to visit the instance settings in kitematic (easier then using the console ). Go to hostname / ports tab. Create a mapping as shown in the image from docker port to host port and bingo. now visit the url again and everything works as expected.

Kitematic instance settings port

  • Note - make sure you use the same port in both docker and published fields. Otherwise some links in the ghost site won't work such as home since they are bound to the docker port. – Gautam Apr 26 '18 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.