docker-ngrok
docker-ngrok copied to clipboard
Issue when docker-compose
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
There is no HTTP_PORT
env variable support. Where did you see that? See https://github.com/wernight/docker-ngrok
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 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?
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
Added NGROK_PORT
, you may also use the command-line directly. Let me know if it helps.
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
@artpi saved my day.
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)
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.
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'
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