Docker Images
Learn how to build and run NGINX Agent docker images
Prerequisites
- Docker must be installed and running
- (Optional) If you plan to use NGINX Plus, you will need the nginx-repo.crt and nginx-repo.key files. You can download them from MyF5.
Building NGINX Agent image with NGINX Open Source
To build an image that contains the latest NGINX Agent and the latest mainline version of NGINX run the following command:
$ cd scripts/docker/official/nginx-oss-with-nginx-agent/alpine/
$ docker build -t nginx-agent . --no-cache -f ./Dockerfile.mainline
To build an image that contains the latest NGINX Agent and the latest stable version of NGINX run the following command:
$ cd scripts/docker/official/nginx-oss-with-nginx-agent/alpine/
$ docker build -t nginx-agent . --no-cache -f ./Dockerfile.stable
Building NGINX Agent image with NGINX Plus
-
Log in to MyF5 Customer Portal and download your
nginx-repo.crt
andnginx-repo.key
files. These files are also provided with the NGINX Plus trial package. -
Copy the files to the directory where the Dockerfile is located
scripts/docker/official/nginx-plus-with-nginx-agent/alpine/
. -
To build an image that contains the latest NGINX Agent and the latest version of NGINX Plus run the following command:
$ cd scripts/docker/official/nginx-plus-with-nginx-agent/alpine/
$ docker build -t nginx-agent . \
--no-cache -f ./Dockerfile \
--secret id=nginx-crt,src=nginx-repo.crt \
--secret id=nginx-key,src=nginx-repo.key
Running NGINX Agent container
Here is an example of how to run a NGINX Agent container:
$ docker run --name nginx-agent -d nginx-agent
By default, the NGINX Agent REST API is not enabled. To enable the API, the NGINX Agent configuration file nginx-agent.conf
needs to be updated to include the API configuration, for example:
api:
host: 0.0.0.0
port: 8038
Once the nginx-agent.conf
file is updated with the API setting, following the previous example, you can run the container with the updated nginx-agent.conf
mounted and the port 8038
exposed with the following command:
$ docker run --name nginx-agent -d \
--mount type=bind,source="$(pwd)"/nginx-agent.conf,target=/etc/nginx-agent/nginx-agent.conf,readonly \
-p 127.0.0.1:8038:8038/tcp \
nginx-agent