Deploy an Azure API Management self-hosted gateway to Docker
This article provides the steps for deploying self-hosted Azure API Management gateway into a Docker environment.
Self-hosted gateway feature is in preview. During the preview, the self-hosted gateway is available only in the Developer and Premium tiers at no additional charge. Developer tier is limited to a single self-hosted gateway deployment.
- Complete the following quickstart: Create an Azure API Management instance
- Create a Docker environment. Docker for Desktop is a good option for development and evaluation purposes. See Docker documentation for information on all Docker editions, their features, and comprehensive documentation on Docker itself.
- Provision a gateway resource in your API Management instance
Self-hosted gateway is packaged as a Linux-based Docker container.
Deploy the self-hosted gateway to Docker
- Select Gateways from under Settings.
- Select the gateway resource you intend to deploy.
- Select Deployment.
- Note that a new token in the Token text box was autogenerated for you using the default Expiry and Secret Key values. Adjust either or both if desired and select Generate to create a new token.
- Make sure Docker is selected under Deployment scripts.
- Select env.conf file link next to the Environment to download the file.
- Select copy icon located at the right end of the Run text box to save the Docker command to clipboard.
- Paste the command to the terminal (or command) window. Adjust the port mappings and container name as needed. Note that the command expects the downloaded environment file to be present in the current directory.
docker run -d -p 80:8080 -p 443:8081 --name <gateway-name> --env-file env.conf mcr.microsoft.com/azure-api-management/gateway:<tag>
- Execute the command. The command instructs your Docker environment to run the container, using self-hosted gateway's image downloaded from the Microsoft Container Registry, and to map the container's HTTP (8080) and HTTPS (8081) ports to ports 80 and 443 on the host.
- Run the below command to check the gateway pod is running:
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 895ef0ecf13b mcr.microsoft.com/azure-api-management/gateway:beta "/bin/sh -c 'dotnet …" 5 seconds ago Up 3 seconds 0.0.0.0:80->8080/tcp, 0.0.0.0:443->8081/tcp my-gateway
- Go back to Azure portal and confirm that gateway node you just deployed is reporting healthy status.
console docker container logs command to view a snapshot of self-hosted gateway log.
docker container logs --help command to see all log viewing options.
- To learn more about the self-hosted gateway, see Azure API Management self-hosted gateway overview.
- Configure custom domain name for the self-hosted gateway.