APISIX offers Docker images that make it easy to deploy and manage APISIX in a containerized environment, providing the benefits of consistency, portability, and flexibility.
This document provides the installation steps for deploying APISIX with Docker in standalone and decoupled deployment modes.
You will need administrator privileges for some of the following steps.
The following steps cover how to install APISIX in standalone mode using Docker and provide one approach to achieve data persistency with Docker volume. Adjust the approach accordingly to integrate with your infrastructure.
Create Configuration Files on Host
To achieve data persistency, create a directory for configuration file and create configuration files
' > ~/conf/apisix.yaml
config.yaml: this file will be initialized in container at startup. It is created on host as an empty file to mount to the container and synchronize with the file content in the container.
apisix.yaml: this file does not exist in container at startup. It is created on host with an example route to mount to the container and avoid any configuration error that may occur.
apisix User on Host
If you use a Debian-based APISIX Docker image, to volume mount files created in the previous step with the appropriate permissions, you should create an
apisix user with the same gid and uid as the
apisix user in the container and change the owner of the configuration files to
Create an user
apisix with uid and gid 636:
groupadd --system --gid 636 apisix
useradd --system --gid apisix --no-create-home --shell /usr/sbin/nologin --uid 636 apisix
Change the ownership of the directory with configuration files to
chown -R apisix:apisix ~/conf
Specify the Docker image tag in an environment variable:
Start APISIX in the standalone mode with configuration files mounted to the container:
docker run -d \
--name apisix-standalone \
-p9080:9080 -p9443:9443 -p9090:9092 \
-e APISIX_STAND_ALONE=true \
--mount type=bind,source="$(pwd)"/conf/apisix.yaml,target=/usr/local/apisix/conf/apisix.yaml \
--mount type=bind,source="$(pwd)"/conf/config.yaml,target=/usr/local/apisix/conf/config.yaml \
Send a request to APISIX to see if it is running:
curl -Is "http://127.0.0.1:9080" | grep Server
If everything is ok, you should see the server version number, such as the following:
Verify Data Persistency
In the previous steps, you have mounted
config.yaml on the host to the corresponding files in the container.
Send a request to the pre-configured route in
curl -i http://127.0.0.1:9080/anything/test
You should see an
HTTP/1.1 201 OK response similar to the following:
"origin": "172.17.0.1, 34.xx.xx.xx",
You can modify configurations in
config.yaml on host, which update the configurations in the container.
apisix.yaml will be loaded automatically to APISIX, whereas changes to
config.yaml will require a reload of APISIX to take effect. See configuration files for more details.