I can't use ghost with docker on domain name or ip != localhost
Everything work, but the home link redirect to localhost:2368 and email invation too.
docker run -d --name some-ghost -p 3001:2368 -v /path/to/ghost/blog:/var/lib/ghost/content ghost:1.8.1-alpine
@MLescaudron this is not an issue with Ghost itself - this has to do with the ghost docker image (which is over at this repo).
However, this is actually solvable, as you can provide environment variables to the ghost instance in order to configure it, see the docs. In your specific case, to run ghost's docker with a different url you would use:
docker run -d --name ghost -p 3001:2368 -e url=http://my-ghost-url.com -v /path/to/ghost/blog:/var/lib/ghost/content ghost:1.8.1-alpine
Closing because this is neither a bug nor an issue related to Ghost itself.
Actually, this didn't universally help. Maybe it's just casper theme that's broken? Posts and stuff work, most nav work, but only the upper left thing is borked:


Nah, casper seems to use a reasonable named variable at least:
Nowhere in the settings can I change this and I do have set the env "url" correctly.
Scrap all my comments. Turns out I misunderstood docker-compose. It doesn't re-read config on restart.
viktor@i7:/var/lib/ghost$ sudo docker-compose restart
Restarting blog ... done
vs
viktor@i7:/var/lib/ghost$ sudo docker-compose stop
Stopping blog ... done
viktor@i7:/var/lib/ghost$ sudo docker-compose up -d
Recreating blog
The docker environment variable isn't working for me in docker-compose. I've tried down/stop and up with build but it's not updating the json file or the URL. Yet if I put quotes around the url it does moan the protocol isn't specified so it is trying to parse it.
I'm using the alpine image. Wonder if that's why...
Map a ghost config file from your host to the container [root dir of ghost] using volume. The URL parameter in your config file will reflect your domain name instead of localhost.
````
$ vi /home/ghost/config/config.production.json
{
"url": "http://SUBDOMAIN.DOMAIN.TLD/",
"server": {
"port": 2368,
"host": "127.0.0.1"
},
$ ghost restart
````
@DwijadasDey Will you please explain a little more simply for a beginner guy like me what you did? i'm having the same issue with ghost redirecting to localhost and don't fully understand how to "Map" the the config file and having trouble finding the "root directory of ghost" as a docker file is that just /var/lib/docker ? I would appreciate any help with further explaining.
@Bellusterra , If you have created the Ghost container using docker run command then you can map the config file from your host machine to container using -v option like the following:
$ docker run -p 80:2368 -v PATH_IN_HOST_MACHINE/config.production.json: PATH_IN_CONTAINER/config.production.json ...
To get the location of the file config.production.json inside container run, docker exec <containerid> /bin/bash and then find the location of the file config.production.json which is your PATH_IN_CONTAINER (Most probably it will be inside /var/lib/ghost). Be sure to edit the parameter url in the config file from your host machine.
@DwijadasDey This won't work because vi/vim/nano is not included in the production Ghost docker image. It uses Alpine.
I just tried to edit it and have no way to do so from within the image.
I was stumped by the localhost:2368 issue running Ghost within Rancher and Docker. I could register a user and access the blog, but was unable to upload images. I think I was able to resolve taking a clue from this comment -- I cloned the Ghost container in Rancher, and there you can set the "url" environment variable, I set it to the IP address that was working for Ghost (instead of I presume the default of localhost) and things seem to be working better now.
setting docker-compose environment as url=\
services:
ghost:
environment:
- url=https://xxx.xxx
@DwijadasDey Thank you for your response. I had a difficult time finding the file you described, I think now it was because I was not in the container itself, so what you suggested may have very well worked for me, so thank you... I ended up when starting the docker container just adding the “-e url=https://my.website.com” to the list of variables which as @nendonerd also suggested is the same as using docker compose file and adding it under the environment variable there. Thank you both for your help.
Most helpful comment
@MLescaudron this is not an issue with Ghost itself - this has to do with the ghost docker image (which is over at this repo).
However, this is actually solvable, as you can provide environment variables to the ghost instance in order to configure it, see the docs. In your specific case, to run ghost's docker with a different url you would use:
Closing because this is neither a bug nor an issue related to Ghost itself.