Restart ghost blog running inside Docker
I’m using the Official Ghost Docker Image, and have ghost running without a problem.
I am developing a theme locally on the host, which is mounted as a volume inside the container. As with any running ghost instance, in order to see the theme changes, I need to stop and restart ghost.
Normally this would simply mean ending the Node process and running
npm start again. But inside the official Docker image, this is not an option. If I try and run
npm start, I’m told:
ERROR: (EADDRINUSE) Cannot start Ghost.
which makes sense, as the port is already in use.
I’ve tried manually killing the processes with no success. If I kill the node process with
kill -9 *node process ID*
The container crashes out. I’ve tried also killing the npm process, but this never seems to go down.
One Solution collect form web for “Restart ghost blog running inside Docker”
This is how i deploy my ghost blog docker:
docker run --name some-blog -d -p 80:2368 -e VIRTUAL_HOST=domain.com -v /home/ghost/blogfiles/:/var/lib/ghost --restart unless-stopped ghost
--restart unless-stopped is useful for when docker containers randomly crash. It will automatically restart them.
Now for your question, list your docker containers by doing a
docker ps you should get something like this:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 11d2517205de ghost "/entrypoint.sh npm s" 2 hours ago Up About a minute 0.0.0.0:80->2368/tcp some-blog
To restart the docker container you can either do
docker stop [container id] and
docker start [container id] or simply
docker restart [container id].