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

Issue when docker-compose #1

Open
lorddaren opened this issue May 10, 2016 · 11 comments
Open

Issue when docker-compose #1

lorddaren opened this issue May 10, 2016 · 11 comments

Comments

@lorddaren
Copy link

When using docker compose I have to set the HTTP_PORT as an environment variable and it will not map to the linked host.

 nginx-proxy:
    container_name: nginx-proxy
    image: nginx
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"
    volumes:
      - "./volumes/conf.d:/etc/nginx/conf.d"
      - "./volumes/vhost.d:/etc/nginx/vhost.d"
      - "./volumes/certs:/etc/nginx/certs:ro"
      - "/usr/share/nginx/html"
 ngrok:
    container_name: ngrok
    ports:
      - "0.0.0.0:4040:4040"
    image: wernight/ngrok
    links:
      - nginx-proxy
    environment:
      - NGROK_AUTH=<auth key>
      - NGROK_SUBDOMAIN=mysubdomain

Am I missing something? If I add the HTTP_PORT things get connected but ngrok complains it can't forward to localhost:80

@wernight
Copy link
Owner

There is no HTTP_PORT env variable support. Where did you see that? See https://github.com/wernight/docker-ngrok

@lorddaren
Copy link
Author

If I don't set it then the ngrok command does not execute appropriately.

In looking at the entrypoint.sh script I believe it is this portion that is hanging me up:

@lorddaren
Copy link
Author

If I don't set it then the ngrok command does not execute appropriately.

In looking at the entrypoint.sh script I believe it is this portion that is hanging me up:

if [ -n "$HTTPS_PORT" ]; then
  FWD="`echo $HTTPS_PORT | sed 's|^tcp://||'`"
elif [ -n "$HTTP_PORT" ]; then
  FWD="`echo $HTTP_PORT | sed 's|^tcp://||'`"
elif [ -n "$APP_PORT" ]; then
  FWD="`echo $APP_PORT | sed 's|^tcp://||'`"
fi

Maybe it is because I am using the newer 1.7 docker-compose and 1.11 docker?

@wernight
Copy link
Owner

I forgot why this is there but it works without, just following the README.

Can also use host:

$ docker run --rm -it --net=host wernight/ngrok ngrok http localhost:80

@wernight
Copy link
Owner

wernight commented Jul 8, 2016

Added NGROK_PORT, you may also use the command-line directly. Let me know if it helps.

@artpi
Copy link

artpi commented Feb 8, 2018

This was tripping me out for a while, until I realized that "NGROK_PORT" can also have a container alias.
So I made it work with:

  nginx:
    depends_on:
      - phpfpm
    ports:
      - "80:80"
      - "443:443"
    image: nginx:latest
    volumes:
      - "./wordpress:/var/www/html"
      - "./config/nginx/default.conf:/etc/nginx/conf.d/default.conf"
      - "./config/certs:/etc/nginx/certs"
      - "./logs/nginx:/var/log/nginx"
    restart: always
  ngrok:
    container_name: ngrok
    ports:
      - "0.0.0.0:4040:4040"
    image: wernight/ngrok
    links:
      - "nginx"
    environment:
      - NGROK_AUTH=<>
      - NGROK_SUBDOMAIN=<>
      - NGROK_REGION=eu
      - NGROK_PORT=nginx:80

@ghost
Copy link

ghost commented Jul 24, 2018

@artpi saved my day.

@andrius
Copy link

andrius commented Dec 17, 2018

Great job, so tiny image! But please add this - NGROK_PORT=nginx:80 to the readme, I've spent some time searching why environment variables does not working (ended up by looking source and entrypoint.sh, then issues)

@wernight
Copy link
Owner

wernight commented Jan 4, 2019

Would you like to suggest a pull-request for the README change? As a user, you're in the best place to know how it could be worded.

@rvanlaak
Copy link

Using docker compose would also work without environment variables when you put the container in the same network:

ngrok:
  container_name: ngrok
  image: wernight/ngrok
  command: ngrok http apache:8080
  networks:
    - apache
  ports:
    -  '4040:4040'

@magentinos
Copy link

magentinos commented Mar 25, 2020

Since "links" is legacy feature, I'd rather use "networks" especially since “links” doesn't work for me
due to error "The error encountered was: dial tcp: lookup nginx on 127.0.0.11:53: no such host"

This way works for me:

nginx:
    image: nginx:alpine
    container_name: nginx
    restart: unless-stopped
    tty: true
    environment:
      SERVICE_NAME: nginx
    ports:
      - 3000:80
    volumes:
      - ./src:/app
      - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - app-network
ngrok:
    container_name: ngrok
    ports:
      - "0.0.0.0:4040:4040"
    image: wernight/ngrok
    environment:
      - NGROK_AUTH=<>
      - NGROK_SUBDOMAIN=<>
      - NGROK_REGION=eu
      - NGROK_PORT=nginx:80
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

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

No branches or pull requests

6 participants