Skip to content

Docker

This quickstart guides you through five steps, installing Traefik Proxy, the Traefik Hub Agent and publishing a service (application) with HTTP authentication.


Introduction

In this example, you will be using a demo application called whoami, a web server answering with host-related information.

Before you begin

Before getting started, make sure you have the following:

1. Install Traefik and the Hub Agent

Login to Traefik Hub and select Install my first Traefik Hub Agent

Choose Docker as platform.

Choose Docker as platform

1.1 Docker network

Copy the content of the code block, by selecting the Copy button and paste it into a CLI and select Enter.

Create Docker network

1.2 Deploy Traefik

Copy the content of the code block, by selecting the Copy button, and paste it into a CLI select Enter.

This will start a Docker container with Traefik Proxy, using the configured Docker network.

Deploy Traefik container

1.3 Deploy the agent

Copy the content of the code block, by selecting the Copy button and paste it into a CLI and select Enter.

welcome to traefik hub

1.4 Save the token

Save the token in a secure place!

Select Copy and save your token.

Save the token in a secure place

Once you are done, select Configuration Done.

2. Start the demo application

Copy the following code block into a CLI and select Enter.

docker run -d -p 8080:80 \
 --network=traefik-hub \
 --name whoami traefik/whoami

3. Name the Agent

Switch back to the Traefik Hub UI and name the Agent.

Name the Hub Agent

4. Publish the service

Now, in the Traefik Hub UI, choose whoami under services and select Publish the service.

Choose whoami service in UI

Publish the service

Before you publish, check that the service port and the network are configured properly.

Make sure to use port 80, this is the port of the whoami application configured in the Docker run command.

Choose the traefik-hub network, this is the network you configured for Traefik and Traefik Hub.

Select Save and Publish.

Service port and network

After a few moments, your service will be ready and published.

Check that the service port(s) and the network are configured, and select Save and Publish.

After a few moments, your service will be ready and published.

You can test it by browsing to the shown URL.

welcome to traefik hub

5. Secure the service

In the next step, you will create and add an Access Control Policy (ACP). This ACP will secure the published service with HTTP authentication.

Select Add Access Control on the whoami overview page.

welcome to traefik hub

Select Create new ACP.

5.1 Create the ACP

Now you will create the ACP (Access Control Policy) to secure the whoami service with basic HTTP authentication.

Create new ACP

HTTP auth

Name

Give it a clear name, identifying what kind of policy it is, for example basic-auth-acp.

Method

Select Basic Auth.

Users

Set a username and a secure password, these will be later used for authentication.

Once you're done, select Save.

5.2 Select Access Control

Assign the created ACP to the service and select Save.

Select ACP

After a few moments, the ACP will be activated.

ACP is selected

Browse to the URL of your demo application.

Login with ACP

Fill in your username and password to reach the application.


In this guide, you learned how to install the Traefik Hub Agent and publishing a service (application) with HTTP authentication using Traefik Hub.

What's next

Now that you've completed this quickstart guide, try these to learn more about Traefik Hub.