question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Application reachable from outside, but not from inside the container

See original GitHub issue

Hello,

I have problem with my application container unable to reach another container behind the nginx reverse proxy.

I have 2 applications running each on different subdomain (and different containers):

app1: app1.domain.com app2: app2.domain.com

I can reach both of them from outside world, it works perfectly. But when I try to reach app2 from app1, it times out. Ping works just fine, DNS records seem to be OK. But wget http://app2.domain.com or wget https://app2.domain.com fails. I think it doesn’t reach the nginx proxy correctly for some reason.

Host machine can access both app1.domain.com and app2.domain.com without any problems. There must be something with docker networking.

I’m running Ubuntu 18.04.4 LTS with Docker 19.03.12, build 48a66213fe

version: "3.1"
services:
  # Nginx proxy - the webserver user will directly face
  # Reverse proxy for all apps, redirects HTTP requests to app
  nginx-proxy:
    image: nginx:1.15-alpine
    container_name: nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - certs:/etc/nginx/certs:ro
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
    restart: always

  # Generator for nginx configuration
  docker-gen:
    image: jwilder/docker-gen
    command: -notify-sighup nginx-proxy -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    container_name: nginx-proxy-gen
    depends_on:
      - nginx-proxy
    volumes:
      - conf:/etc/nginx/conf.d
      - vhost:/etc/nginx/vhost.d
      - certs:/etc/nginx/certs:ro
      - ./docker/nginx/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.docker_gen"
    restart: always

  # Container to generate SSL certificates
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nginx-proxy-le
    depends_on:
      - nginx-proxy
      - docker-gen
    volumes:
      - vhost:/etc/nginx/vhost.d
      - html:/usr/share/nginx/html
      - certs:/etc/nginx/certs
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: always

  # Actual app
  app:
    image: registry.gitlab.com/klinki/docker-registry/app:latest
    expose:
      - "80"
    environment:
      VIRTUAL_HOST: app1.domain.com
      LETSENCRYPT_HOST: app1.domain.com
      LETSENCRYPT_EMAIL: admin@domain.com

  app_pse:
    image: registry.gitlab.com/klinki/docker-registry/app2:latest
    environment:
      VIRTUAL_HOST: app2.domain.com
      LETSENCRYPT_HOST: app2.domain.com
      LETSENCRYPT_EMAIL: admin@domain.com

volumes:
  conf:
  vhost:
    driver: local
    driver_opts:
      type: "none"
      o: "bind"
      device: "/root/inviser/docker/nginx/vhost.d"
  html:
  certs:
  dbvolume:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
klinkicommented, Jul 18, 2020

@tkw1536 Firewall was good idea! I’m confused why it worked from the outside, but I was missing ports 80 and 443 in ufw. I added rule to allow all traffic on these ports and now it works.

0reactions
ugened47commented, Jul 12, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker container reachable from the inside but not the outside
I'm new to docker and I'm trying to deploy a flask app using docker container but I cannot access it via http://host_ip:port.
Read more >
Docker Container not reachable from the outside (only after ...
Docker is running on a raspberry pi model 4. I use macvlan with define/ unique IPs and MACs as I want to access...
Read more >
Some Containers Are Not Accessible by the Outside Network
Some containers cannot be accessed from outside the network. Others can. The ones that can't be accessed are fully accessible from inside ...
Read more >
Docker ports do not seem to be reachable from outside server
Here, our Docker container is reachable through docker0 (network: 172.17.x.x). From your browser, you're trying to connect to some 10.
Read more >
How to access docker container application from outside
You might be confused do expose docker container application to expose external world. This video helps to do that.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found