can't link nginx with ghost in docker

I am deploying a ghost server on digitalocean with port default to 2368.

docker run -d --name ghost ghost

and also I deploy a nginx server as well.

  • Alternating provisioning with Vagrant
  • Docker-compose and Docker-swarm
  • Can I somehow see my Docker Hub images being built via Github hooks?
  • Docker container bridged interface to assign IP address
  • Building a docker image for a node.js app fails behind proxy
  • Docker on windows: data in mounted volume doesn't updated
  • docker run -d -p 80:80 -p 443:443 --name nginx --link ghost:ghost -v /home/abc/nginx/sites-enabled:/etc/nginx/sites-enabled nginx

    under the path of /home/abc/nginx/sites-enabled, I have a config file – named as ghost

    server {
      server_name mydomain; 
      access_log /var/log/nginx/; 
      location / {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header HOST $http_host;
          proxy_set_header X-NginX-Proxy true;
          proxy_pass http://ghost:2368;
          proxy_redirect off;

    at last

    docker restart nginx,ghost

    I can clearly the nginx and ghost container is running well, and go to the IP address of server, I can see the welcome page of nginx, which says

    If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

    but go to the domain, it can’ find the server or sometimes show the nginx welcome page as well

  • Reach host with Docker Compose
  • Docker container data lost on host restart
  • Wercker crashes on MacOS with PANIC too many open files
  • Bamboo “cannot connect to Docker daemon”
  • Docker Exec -it bash Terminal Output Improperly Formatted [duplicate]
  • Provisioning vagrant machine: The Dockerfile (Dockerfile) must be within the build context
  • 2 Solutions collect form web for “can't link nginx with ghost in docker”

    First, Your volume mapping should be -v /home/abc/nginx/sites-enabled:/etc/nginx/conf.d, not site-enabled.

    Second, because Nginx loads DNS entries when it starts up and never updates, Nginx won’t be able to locate your ghost container after ghost restarts (and thus gets a new IP address). A quickfix is to run docker restart ghost nginx instead of docker restart nginx ghost.

    Try this pre-setup nginx proxy

    Following the instructions I run the nginx proxy:

    docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

    Then you can simply run the ghost docker something like this:

    docker run --name some-blog -d -p 80:2368 -e -v /home/ghost/someblog/:/var/lib/ghost --restart unless-stopped ghost

    I have multiple ghost containers setup like this.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.