Hi,
I’m just learning docker and playing around by hosting ghost on containers. Initially, I managed to get ghost up and running and was able to access successfully from a custom domain. Then i spun up another container for the same ghost application and bound it to a different port. I did this to try two different ghost themes . But I seem to have broken the system. I’m unable to access from an external domain. It works when i acess from the local host
WARNING: No memory limit support
WARNING: No swap limit support
WARNING: No kernel memory limit support
WARNING: No oom kill disable support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
I have removed the other container. Right now I am only running one container. I also found that I can’t access the ghost application . When I curl I get an error
I found that am getting this error after I restarted my container
pi@ud-kube-master:~ $ curl http://localhost:3500 curl: (56) Recv failure: Connection reset by peer
pi@ud-kube-master:~ $
Btw…I tried to remove to troubleshoot where I was going.now after the restart I can’t access the ghost application landing page. I could access the application if I remove and run again. I get the curl error whenever I restart the container
#!/bin/bash
set -e
# allow the container to be started with `--user`
if [[ "$*" == node*current/index.js* ]] && [ "$(id -u)" = '0' ]; then
chown -R node "$GHOST_CONTENT"
exec gosu node "$BASH_SOURCE" "$@"
fi
if [[ "$*" == node*current/index.js* ]]; then
baseDir="$GHOST_INSTALL/content.orig"
for src in "$baseDir"/*/ "$baseDir"/themes/*; do
src="${src%/}"
target="$GHOST_CONTENT/${src#$baseDir/}"
mkdir -p "$(dirname "$target")"
if [ ! -e "$target" ]; then
tar -cC "$(dirname "$src")" "$(basename "$src")" | tar -xC "$(dirname "$target")"
fi
done
knex-migrator-migrate --init --mgpath "$GHOST_INSTALL/current"
fi
exec "$@
but that is executing curl INSIDE the container… not on the docker host. localhost INSIDE the container is INSIDE the container… (ie 172.17.0.2)… NOT the docker host IP address
-p 3500:80
means 3500 port on HOST will send traffic to container port 80
this is how you can have multiple instances of the identical container running on the same host…
the same container port number is mapped to a different host port for each container instance
the code in the container DOES NOT KNOW the port is mapped.
try not using localhost… but the containers internal IP address… but then you would use the container applications listening port (usually 80 for web applications), not the host port number
i am not sure we are talking about the same thing…
docker run -d -name fred -p 2500:80 foo
docker run -d -name mark -p 3500:80 foo
the from the docker host, you can access the application in fred with
localhost:2500 OR hosts-ip_address:2500, OR (container_ip address:80, 172.17.0.2 usually)
you can ALSO connect to container fred from another machine on a network accessible to the docker HOST with
docker_host_ip_address:2500
but NEVER with the containers IP address…
same applies to container mary, only using host port 3500
INSIDE the container you can access the application using localhost:80, or the containers IP address:80, 172.17.0.2:80
but NOT the port number of the mapping to the host
hmm…if I use the container ip I wil not be able to access it from the internet. Sorry, I’m still a novice user here. I was able to access the site using the localhost:3500 when I spin up the container. It stops working only after I restart the container . During restart some parameter is changing thats creating this issue but not sure what it is. From the stackoverflow link I see a similar issue but looks like something has to be done with nodejs .
I created a container using the following command docker run -d -p 3500:2368 --restart unless-stopped -v /var/lib/ghost/content --name blog-ghost --volumes-from ghost-data arm32v7/ghost:latest
Once the container is up and running , I could access the container from the host as you had pointed out
docker_host_ip_address:3500
Until this step everything works fine. If I restart , then am unable to use the docker_host_ip_address:portnumber to access the blog. I am getting an error.
Here’s the log output and error
INFO [2018-02-21 11:56:59] “GET /” 200 1094ms
INFO [2018-02-21 11:59:25] “GET /” 200 313ms
INFO [2018-02-21 12:12:43] “GET /” 200 319ms
INFO [2018-02-21 12:56:19] “GET /” 200 254ms
INFO [2018-02-21 14:44:20] “GET /” 200 242ms
[2018-02-21 14:46:02] WARN Ghost has shut down
[2018-02-21 14:46:02] WARN Your blog is now offline
[2018-02-21 14:46:10] INFO Finished database migration!
[2018-02-21 14:46:21] INFO Ghost is running in production…
[2018-02-21 14:46:21] INFO Your blog is now available on http://localhost:3500/
[2018-02-21 14:46:21] INFO Ctrl+C to shut down
[2018-02-21 14:46:21] INFO Ghost boot 10.607s
INFO [2018-02-21 15:48:58] “GET /” 200 1113ms
INFO [2018-02-21 15:51:01] “GET /” 200 347ms
INFO [2018-02-21 15:52:23] “GET /” 200 286ms
INFO [2018-02-21 15:58:06] “GET /” 200 245ms
INFO [2018-02-21 17:10:41] “GET /” 200 259ms
pi@kube-master:~ $ curl http://localhost:3500
curl: (56) Recv failure: Connection reset by peer