# Ghost and Docker, a lot of problems!

**URL:** <https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710>\
**Category:** Developer help\
**Created:** [July 8, 2020, 3:02pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710 "2020-07-08T15:02:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mantegnous](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mantegnous/32/8354_2.png) [@mantegnous](https://forum.ghost.org/u/mantegnous)\
**Post date:** [July 8, 2020, 3:02pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/1 "2020-07-08T15:02:45Z")

</div>

Hi, hi installed ghost on my machine with docker,  
I followed the official tutorial and the official image.

I used this comand

```auto
docker run -d --name some-ghost -e url=http://my-server-adress.com -p 80:2368 ghost

```

because the standard comand

```auto
 docker run -d --name some-ghost ghost

```

doesn’t show me ghost in [my-server-adress.com:2368](http://my-server-adress.com:2368) (the door is open)

So, i configured ghost from [my-server-adress.com/ghost](http://my-server-adress.com/ghost),  
but i have a lot of problem:

1. I can’t invite staff because ghost tell me to configure mail service (direct mail no works…)
2. I go on the container and i open the terminal:

i use ghost cli for configurate the email service with my gmail credentials  
after this, the comand ghost restart doesn’t work because im the root user.  
so, i switch my user to node user, but i have another error:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/7/7aed8bb676f039990eb3bfa02e3a73a62e623b43.png)

so, at this point, i restart the docker container, but after this comand, the website return me a 502 error.  
when i go to check the config.production.json file i see two difference:

the port was 2368 now is 2369, the host ip was 0.0.0.0 now is 127.0.0.1…

so, after this change im not able to use ghost again, i need to create another container!

who can help me?

---

<div class="post-metadata">

**Author:** ![egg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/egg/32/1691_2.png) [@egg](https://forum.ghost.org/u/egg)\
**Post date:** [July 8, 2020, 3:23pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/2 "2020-07-08T15:23:59Z")

</div>

Hey!

It’s worth noting that the “official image” is not official from Ghost, it’s official from Docker - we do not maintain nor support it! You may get better help on their GitHub ([GitHub - docker-library/ghost: Docker Official Image packaging for Ghost](https://github.com/docker-library/ghost)) or forums!

That said, we can try our best to help you!

> doesn’t show me ghost in [my-server-adress.com:2368](http://my-server-adress.com:2368) (the door is open)

This is because you mapped the ports with your command `-p 80:2368` this forwards your host machines port 80 to the containers port 2368 - so unless you have another instance running, there will not be a Ghost server listening on [my-server-address.com:2368](http://my-server-address.com:2368), it should just be [my-server-address.com](http://my-server-address.com)

> i use ghost cli for configurate the email service with my gmail credentials  
> after this, the comand ghost restart doesn’t work because im the root user.  
> so, i switch my user to node user, but i have another error:

As far as I understand the docker image is supposed to be configured with environment variables, I may be wrong, but you should check with them how you’re supposed to configure mail.

Our docs how on to configure Ghost include information on how to use environment variables: [Configuration - Adapt your publication to suit your needs](https://ghost.org/docs/concepts/config/#running-ghost-with-config-env-variables)

Hopefully this gets you onto the right track!

---

<div class="post-metadata">

**Author:** ![mantegnous](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mantegnous/32/8354_2.png) [@mantegnous](https://forum.ghost.org/u/mantegnous)\
**Post date:** [July 8, 2020, 3:28pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/3 "2020-07-08T15:28:58Z")

</div>

Fabien this [my-server-adress.com:2368](http://my-server-adress.com:2368/) doesnt work because i used command to set port 80, but if i use the standard comand without change port, i dont see difference, i see a big 502 error…

So, i followed the ghost tutorial for configure email with ghost cli but i can’t find where and how configure docker env variables

---

<div class="post-metadata">

**Author:** ![egg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/egg/32/1691_2.png) [@egg](https://forum.ghost.org/u/egg)\
**Post date:** [July 8, 2020, 3:39pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/4 "2020-07-08T15:39:31Z")

</div>

You’ll need to be a bit more explicit if you want help, what is the “standard command”?

You have already configured the `url` environment variable with docker using the `-e` flag ([docker run | Docker Documentation](https://docs.docker.com/engine/reference/commandline/run/))

If you are struggling with docker, I would suggest using the ghost-cli and following our official docs for installing on an ubuntu server [How to install & setup Ghost on Ubuntu 16.04, 18.04, 20.04 or 22.04](https://ghost.org/docs/install/ubuntu/)!

---

<div class="post-metadata">

**Author:** ![mantegnous](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mantegnous/32/8354_2.png) [@mantegnous](https://forum.ghost.org/u/mantegnous)\
**Post date:** [July 8, 2020, 3:41pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/5 "2020-07-08T15:41:31Z")

</div>

This will start a Ghost instance listening on the default Ghost port of 2368.

```auto
$ docker run -d --name some-ghost ghost

```

so, i aspect to see my ghost on [my-server-adress.com:2368](http://my-server-adress.com:2368)… but i have a 502 error

so, for this reason i used this comand:

```auto
 docker run -d --name some-ghost -e url=http://myserver.com -p 80:2368 ghost

```

---

<div class="post-metadata">

**Author:** ![egg](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/egg/32/1691_2.png) [@egg](https://forum.ghost.org/u/egg)\
**Post date:** [July 8, 2020, 3:44pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/6 "2020-07-08T15:44:08Z")

</div>

Just running a container doesn’t map your container port to your host ports, you’ll need to run it with `-p 2368:2368`

As for the 502 error, do you have any other server software running on your machine? What is serving the 502?

---

<div class="post-metadata">

**Author:** ![mantegnous](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mantegnous/32/8354_2.png) [@mantegnous](https://forum.ghost.org/u/mantegnous)\
**Post date:** [July 8, 2020, 3:46pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/7 "2020-07-08T15:46:58Z")

</div>

```
docker run -d --name some-ghost -e url=http://myserver.com:2368 -p 2368:2368 ghost

```

i used this command, but i dont see difference, at [myserver.com:2368](http://myserver.com:2368) i see a 502 error… but if i change the port with 80 works

---

<div class="post-metadata">

**Author:** ![mantegnous](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mantegnous/32/8354_2.png) [@mantegnous](https://forum.ghost.org/u/mantegnous)\
**Post date:** [July 8, 2020, 3:54pm UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/8 "2020-07-08T15:54:34Z")

</div>

so, i dont use ghost cli if i’m using docker? i dont know docker and i dont know were are the ghost’ env variable for docker… i know that existe a config.production.json file with this information… but this can be edit by ghost cli, but i change this values, docker stop working

---

<div class="post-metadata">

**Author:** ![mantegnous](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mantegnous/32/8354_2.png) [@mantegnous](https://forum.ghost.org/u/mantegnous)\
**Post date:** [July 9, 2020, 6:47am UTC](https://forum.ghost.org/t/ghost-and-docker-a-lot-of-problems/15710/9 "2020-07-09T06:47:31Z")

</div>

Who can help me?
