Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO: Developer | Premium
This article provides the steps for deploying self-hosted gateway component of Azure API Management to a Docker environment.
Note
Hosting a self-hosted gateway in Docker is best suited for evaluation and development use cases. Kubernetes is recommended for production use. Learn how to deploy a self-hosted gateway to Kubernetes with Helm or by using a deployment YAML file.
Prerequisites
- 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 Azure API Management instance.
Note
Self-hosted gateways are packaged as x86-64 Linux-based Docker containers.
Deploy the self-hosted gateway to Docker
Select Self-hosted gateways under Deployment + infrastructure.
Select the gateway resource you want to deploy.
Select Settings > Deployment.
Note that an access token in the Token text box is autogenerated for you by 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 the env.conf file link next to the Environment to download the file.
Select the Copy icon located at the right end of the Run text box to copy the Docker command to your clipboard.
Paste the command to the terminal (or command) window. Adjust the port mappings and container name as needed. The command assumes that the 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 by 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 following 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-gatewayGo back to Azure portal, select Overview, and confirm that the self-hosted gateway container you just deployed reports a healthy status.

Tip
Use console docker container logs <gateway-name> command to view a snapshot of self-hosted gateway log.
Use docker container logs --help command to see all log viewing options.
Related content
- To learn more about the self-hosted gateway, see Self-hosted gateway overview.
- Configure a custom domain name for a self-hosted gateway.