Enable port forwarding on a Docker container in Q Blocks instance

There could be a scenario where you want to publicly access the running docker container application in your instance. Docker containers support port forwarding through which you can access the application running inside your container at a specified port through browser or APIs.

Q Blocks instances come with an open port by default that can be used to make an application running inside it publicly accessible.

This example assumes that docker engine is already installed in your Q Blocks instance, if not then we would recommend to first install it via this guide.

For this example we will use Nagios application docker Image:

docker pull jasonrivers/nagios

Nagios is a monitoring tool and this image is used to launch a container with the Nagios application running inside the container at Port 80. Now to make it viewable on browser we will use port forwarding on the docker container run command.

To enable port forwarding on a container running inside your Q Blocks instance, follow the steps below:

  1. Click on the "More info" button for your instance on the Instances page in your Dashboard.

  2. Copy the Extra Port and Host URL as shown in the image:

  1. Run the docker container command as follows:

docker run --name nagios4 -p EXTRA_PORT:80 -d jasonrivers/nagios:latest
  1. Now access the container application in your browser at the following URL:

http://HOST_URL:EXTRA_PORT

This should help you get started with running port forwarded containerized applications that can be accessible publicly.

Word of Caution:

Any application running at a forwarded port is accessible to the public. Right precautions with auth token or password access must be implemented to secure the applications.

If you still face issues setting it up then don't hesitate to reach out to us at: support@qblocks.cloud

Last updated