Using ngrok with Docker
ngrok provides pre-built docker images for the ngrok Agent with instructions for getting started. An example command for starting a tunnel to port 80
on the host machine looks like this:
Loading…
Note: the Docker version of ngrok follows the same convention as the agent, for example:
Loading…
For MacOS or Windows users, the --net=host
option will not work. You will need to use the special url host.docker.internal
as described in the Docker networking documentation.
Loading…
This also applies to the upstream addr
in your ngrok config file. For example:
Loading…
Using ngrok with Docker Compose
If you're more comfortable using Docker Compose, you can use the following as a starting point. Copy the contents below into a new file named docker-compose.yaml
, then run docker compose up
in that directory. This Docker compose file assumes that you have an ngrok.yml
file in the same directory with at least one tunnel defined. Check out the ngrok agent config file documentation for help creating a configuration file with a tunnel definition. If you want to use the same configuration file as your local ngrok agent, you can view the location of the default config file using ngrok config check
.
Loading…
If you're defining your tunnels directly in docker-compose.yaml
rather than using an ngrok.yml
file the configuration will look a little different. Your command will be running an ngrok http
command and you'll be using the special url host.docker.internal
as mentioned in the note above. The following is an example of using the ngrok along with the dockersamples/static-site
image.
Loading…