2.8 KiB
sidebar_position | sidebar_label |
---|---|
10 | Public Share |
Docker Public Share
With zrok, you can publicly share a server app that's running in another Docker container, or any server that's reachable by the zrok container.
Walkthrough Video
Before You Begin
To follow this guide you will need Docker and the Docker Compose plugin for running docker compose
commands in your terminal.
Public Share with Docker Compose
-
Make a folder on your computer to use as a Docker Compose project for your zrok public share.
-
In your terminal, change directory to your newly-created project folder.
-
Download the zrok-public-share Docker Compose project file into your new project folder.
-
Copy your zrok environment token from the zrok web console to your clipboard and paste it in a file named
.env
in the same folder like this:# file name ".env" ZROK_ENABLE_TOKEN="8UL9-48rN0ua"
-
If you are self-hosting zrok then it's important to set your API endpoint URL too. If you're using the hosted zrok service then you can skip this step.
# file name ".env" ZROK_API_ENDPOINT="https://zrok.example.com"
-
Run your Compose project to start sharing the built-in demo web server:
docker compose up
-
Read the public share URL from the output. One of the last lines is like this:
zrok-public-share-1 | https://w6r1vesearkj.in.zrok.io/
You can swap in a different server app container instead of the demo server, or you could change the Docker network to "host" and share something running on the Docker host's localhost interface.
-
Edit the file
docker-compose.yml
. Replace the following line:command: share public --headless http://zrok-test:9090
Replace that line with this to start sharing the HTTPBin server app container instead of the zrok test endpoint.
command: share public --headless http://httpbin-test:8080
-
Re-run your project to load the new server configuration.
docker-compose up --force-recreate
Now you'll have a new public share URL for the
httpbin
API testing server. -
Run "down" to destroy the Compose project when you're done. Then delete the selected zrok environment by clicking "Actions" in the web console.
docker compose down --remove-orphans --volumes