Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Ghost redirect to localhost:2368 #8966

Closed
mlescaudron opened this issue Sep 2, 2017 · 12 comments
Closed

Docker Ghost redirect to localhost:2368 #8966

mlescaudron opened this issue Sep 2, 2017 · 12 comments

Comments

@mlescaudron
Copy link

@mlescaudron mlescaudron commented Sep 2, 2017

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
@acburdine

This comment has been minimized.

Copy link
Member

@acburdine acburdine commented Sep 2, 2017

@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.

@acburdine acburdine closed this Sep 2, 2017
@hedefalk

This comment has been minimized.

Copy link

@hedefalk hedefalk commented Jan 31, 2018

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:

image

image

@hedefalk

This comment has been minimized.

Copy link

@hedefalk hedefalk commented Jan 31, 2018

Nah, casper seems to use a reasonable named variable at least:

https://github.com/TryGhost/Casper/blob/bfaae0f7ba5c4b9d70d9f37b65ea765257aa5486/partials/site-nav.hbs#L5

Nowhere in the settings can I change this and I do have set the env "url" correctly.

@hedefalk

This comment has been minimized.

Copy link

@hedefalk hedefalk commented Jan 31, 2018

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
@richmidwinter

This comment has been minimized.

Copy link

@richmidwinter richmidwinter commented Jul 21, 2018

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...

@DwijadasDey

This comment has been minimized.

Copy link

@DwijadasDey DwijadasDey commented Aug 9, 2018

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

@Bellusterra

This comment has been minimized.

Copy link

@Bellusterra Bellusterra commented Aug 30, 2018

@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.

@DwijadasDey

This comment has been minimized.

Copy link

@DwijadasDey DwijadasDey commented Aug 30, 2018

@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.

@Dynamic-Gravity

This comment has been minimized.

Copy link

@Dynamic-Gravity Dynamic-Gravity commented Sep 20, 2018

@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.

@mossmoss

This comment has been minimized.

Copy link

@mossmoss mossmoss commented Nov 15, 2018

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.

@nendonerd

This comment has been minimized.

Copy link

@nendonerd nendonerd commented Dec 22, 2018

setting docker-compose environment as url=<your site> works, but mind that it's CASE-SENSITIVE, only 'url' works but not 'URL'

services:
    ghost:
        environment:
            - url=https://xxx.xxx
@Bellusterra

This comment has been minimized.

Copy link

@Bellusterra Bellusterra commented Dec 26, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.