Configuring Argo tunnel for a httpbin server using Docker

Hi,
I am trying to configure an Cloudflare Tunnel for a simple httpbin app using docker.

Currently, docker run <my_image> fails to start cloudflared

[ec2-user@ip-172-31-86-153 httpbin]$ sudo docker run argo_httpbin
/usr/lib/python2.7/dist-packages/supervisor/options.py:298: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a “-c” argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching ’
2019-09-08 08:52:45,247 CRIT Supervisor running as root (no user in config file)
2019-09-08 08:52:45,251 INFO supervisord started with pid 1
2019-09-08 08:52:46,254 INFO spawned: ‘httpbin’ with pid 8
2019-09-08 08:52:46,264 INFO spawned: ‘cloudflared’ with pid 9
2019-09-08 08:52:46,718 INFO exited: cloudflared (exit status 1; not expected)
2019-09-08 08:52:47,872 INFO success: httpbin entered RUNNING state, process has stayed up for
than 1 seconds (startsecs)

Here is my dockerfile:

FROM ubuntu:18.04

RUN apt-get -yqq update
COPY . /opt/flaskapp
WORKDIR /opt/flaskapp

Supervisord

RUN apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
RUN mkdir -p /etc/supervisor/conf.d/
COPY supervisord.conf /etc/supervisord.conf

Cloudflared

RUN apt-get install -y wget
RUN wget -O- https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.tgz | tar xz
RUN mkdir -p /etc/cloudflared/
COPY cert.pem /etc/cloudflared/
COPY config.yml /etc/cloudflared/

HTTPBin

RUN apt install python3-pip git -y && pip3 install --no-cache-dir pipenv

ADD Pipfile Pipfile.lock /httpbin/
WORKDIR /httpbin
RUN /bin/bash -c “pip3 install --no-cache-dir -r <(pipenv lock -r)”

ADD . /httpbin
RUN pip3 install --no-cache-dir /httpbin
RUN pip3 install gunicorn

CMD [“/usr/bin/supervisord”]

My config.yml:
hostname: tunnel.koshaparekh.tk
url: https://localhost:8000
logfile: /var/log/cloudflared.log

My supervisord.conf
[supervisord]
nodaemon = true

[program: cloudflared]
command=/opt/flaskapp/cloudflared
autostart=true
autorestart=true
startretries=3
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

[program:httpbin]
command=gunicorn -b 0.0.0.0:80 httpbin:app -k gevent
autostart=true
autorestart=true
startretries=3
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0

What am I doing incorrectly?

:wave: @kosha.parekh,

I am just a pug… and I am on my way out to the dog park to play with my friends. But at first glance it appears you have your tunnel listening on port 8000 and your application listening on port 80 in your configuration file.

-OG

1 Like

Hi!
Thank you for pointing that out, I fixed httpbin to run on 127.0.0.1:8000
command=gunicorn -b 127.0.0.1:8000 httpbin:app -k gevent

Now when I run “docker run <my_image>” it enters running state but immediately exits with status code 1

2019-09-08 15:35:36,149 INFO supervisord started with pid 1
2019-09-08 15:35:37,152 INFO spawned: ‘httpbin’ with pid 8
2019-09-08 15:35:37,187 INFO spawned: ‘cloudflared’ with pid 9
2019-09-08 15:35:38,803 INFO success: httpbin entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-09-08 15:35:38,803 INFO success: cloudflared entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-09-08 15:35:40,144 INFO exited: cloudflared (exit status 1; not expected)
2019-09-08 15:35:41,147 INFO spawned: ‘cloudflared’ with pid 20
2019-09-08 15:35:42,279 INFO success: cloudflared entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2019-09-08 15:35:43,283 INFO exited: cloudflared (exit status 1; not expected)