I was originally using Ghost 0.11.x and figured it was time to upgrade to the latest version. I ran the docker container 1.0 and imported my stuff, and then ran the container for 2.0 (had a mounted volume so data persisted). This more or less worked, but a lot of the urls were broken, using localhost:2368 instead of my blog url. I looked it up and saw that I’m supposed to use -e url=https://domain.here but that didn’t work. For some reason, that particular environment variables causes it fail.
I’m not sure if this is affecting it, but my ghost container is also behind a Caddy reverse-proxy. My domain maps to my server IP, from which Caddy maps the request to that domain to the docker container IP. e.g.
blog.domain.com {
proxy / 172.17.0.7:2368
}
Now, when I run the following docker command: docker run -d --name ghost -v /home/ghost:/var/lib/ghost/content ghost, it starts fine. When I navigate to blog.domain.com, Caddy routes everything correctly and I see my blog. But the links are broken like I mentioned, going to http://localhost:2368/etc.
When I run docker run -d --name ghost -e url=https://blog.domain.com -v /home/ghost:/var/lib/ghost/content ghost, everything breaks. Attempting to navigate to blog.domain.com hangs for a while, then the url changes to https://172.17.0.7:2368/ and fails to connect.
This only happens when I use the url environment variable. I tried other combinations, including the port flag, setting the NODE_ENV variable, using 1-alpine instead of 1, etc. Nothing worked.
How do I get past this? I don’t want to run ghost outside of a docker container, but there doesn’t seem to be many resources on how to fix this issue, as everyone points to that environment variable, but it’s not working here.
I originally had this problem because I wasn’t using ‘url’ as all lower case in my environment variable. It looks like you might not have that problem, but I’m mentioning it just in case it is helpful.
Bumping in case anyone new can help. I thought perhaps the theme was the issue but im sure ghost itself is having issues using the url properly. When not setting the environment variable, it tries using localhost:2368 still, even on the ghost admin page.
That looks really interesting - I know that I’ve had some problems running the standard docker image under Azure and getting persistent data. I think it might be down to some magic with setting the volume correctly and your configuration there has given me an idea
I tried using your fork and I ran into the same issue. If I leave the url parameter as localhost:2368, then the site is broken as links to the homepage or back to the site from the editor will try going to localhost:2368 instead of the url I want. If I set the url parameter to my domain, the site redirects to https://172.17.0.5:2368/ (the container ip) upon connecting, and fails to connect. I’m pretty sure the DNS is setup properly as I’m doing the same thing I did for my ghost v0.11 instance (DNS from domain registrar points to my droplet IP, and from there Caddy proxies requests to the corresponding container).
I see you had a proxy issue. It’s always the case :-p
Seriously, the docker image is stable for over 2 years and my guess is that 1000s of people are using/testing it every day. The docker image I maintain has been pulled more than 5M times (I’m like what? really ?).
I think just adding a note that people using it behind proxies should try running it as transparent. I’m not exactly sure why it works, perhaps someone more knowledgeable on the topic can chime in. The caddy docs has a little bit on what transparent does on this page: https://caddyserver.com/docs/proxy (just scroll down a bit).
My only question now I guess is what changed in ghost that required the transparent directive, would be useful to identify in other projects to avoid this headache later.