Deploy an Azure API Management self-hosted gateway to Docker
This article provides the steps for deploying self-hosted gateway component of Azure API Management to a Docker environment.
Support for Azure API Management self-hosted gateway version 0 and version 1 container images is ending on 1 October 2023, along with its corresponding Configuration API v1. Use our migration guide to use self-hosted gateway v2.0.0 or higher with Configuration API v2. Learn more in our deprecation documentation
Hosting self-hosted gateway in Docker is best suited for evaluation and development use cases. Kubernetes is recommended for production use. Learn how to deploy with Helm or using deployment YAML file to learn how to deploy self-hosted gateway to Kubernetes.
This feature is available in the Premium and Developer tiers of API Management.
- 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 x86-64 Linux-based Docker container.
Deploy the self-hosted gateway to Docker
Select Gateways from under Deployment and infrastructure.
Select the gateway resource you intend to deploy.
Note that an access token in the Token text box was autogenerated for you using the default Expiry and Secret key values. If needed, pick desired values in either or both controls to generate 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 copy 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 assumes that downloaded environment file is 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 a container image from the Microsoft Artifact 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 if the gateway container is running:
docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 895ef0ecf13b mcr.microsoft.com/azure-api-management/gateway:latest "/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, click on Overview and confirm that self-hosted gateway container you just deployed is reporting a healthy status.
console docker container logs <gateway-name> 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.
Submit and view feedback for