docker-ngrok
docker-ngrok copied to clipboard
Auth token?
Thanks a lot looks great !!! How can I add an auth token ? I tried docker run ngrok-container ngrok authtoken 'authToken' but it writes me:
t=2016-07-07T14:52:06+0000 lvl=warn msg="failed to get home directory, using $HOME instead" err="user: Current not implemented on linux/amd64" $HOME=/home/ngrok
Failed to save authtoken to configuration file '/home/ngrok/.ngrok2/ngrok.yml': open /home/ngrok/.ngrok2/ngrok.yml: permission denied
Would it be hard to programatically support changing env variable NGROK_AUTH ?
Ah thanks I cannot test this but it seems like an easy fix.
Normally the access right should be fine thanks to this line:
chown ngrok:ngrok /home/ngrok
Are you mounting volumes? Running as another user?
Thanks for the fast answer.
Here is my Dockerfile: FROM wernight/ngrok:latest ENV NGROK_AUTH 'auth_key' CMD ["ngrok", "start", "--none"]
If you specify CMD
you cannot use environment variables. Updating README. Either using only environment variables, or use only the CMD
and put the token in the command-line.
Interesting, I would like the service to be started when the container launches, and don't want the users to manually run the command ngrok start --none. Could you think of a workaround for it to work out-of-the box? I tried putting in the CMD the auth key but didn't succeed for some reason...
Thanks a lot for your help!
NGROK_AUTH
does only generate a command-line like:
`ngrok http -authtoken=$TOKEN -log stdout`
Now I understand better thanks. Still I would be very glad to be able to set the authtoken programmatically with an ENV variable NGROK_AUTH, because multiple devs are gonna use the same image, and the only change between each would be the auth token...
Do you think the other docker images of ngrok (including the ones you forked from) could work out for my use case ? Thanks
I've seen none doing a ngrok start --none
. You can just create a Dockerfile and extend this one, or use docker-compose.yml
to write your environment.
Ah ha! I figure out the problem is.
I found the default config file's owner is root
, not ngrok
user.
/ $ ls -al /home/ngrok/.ngrok2/ngrok.yml
-rw-r--r-- 1 root root 23 Jul 4 07:38 /home/ngrok/.ngrok2/ngrok.yml
that will cause error for ngrok authtoken
command
My workaround fix
First, I make a Dockerfile for fix this issue
$ vi Dockerfile
content as follows
FROM wernight/ngrok:latest
USER root
RUN chown -R ngrok:ngrok /home/ngrok/
USER ngrok
(or change it to RUN chown ngrok:ngrok /home/ngrok/.ngrok2/ngrok.yml
)
Second, build it as new image
$ docker build . -t j/ngrok:latest
then use it
$ docker run --rm -it j/ngrok sh -c "ngrok authtoken MY_AUTH_TOKEN ; ngrok tcp 12345"
replace MY_AUTH_TOKEN
to yours
Maybe I solution is not the best answer, but works.
Same shit with ngrok installed from snap on ubuntu 18 laptop:
$ ngrok authtoken <token>
ERROR: Failed to save authtoken to configuration file '/home/alex/.ngrok2/ngrok.yml': open /home/alex/.ngrok2/ngrok.yml: permission denied
And ok with unzipped one.