Quick Start Guide
This guide will walk you through the basic steps to get an OpenResty container running on your machine.
Prerequisites
Ensure you have Docker installed and running on your system.
Step 1: Pull an OpenResty Image
First, pull a recommended image from Docker Hub. The Debian Bookworm image is a great general-purpose choice.
docker pull openresty/openresty:bookworm
You can see a full list of available images in the Image Tags & Pulling section.
Step 2: Run a Container
Run a container in detached mode (-d) and map your local port 8080 to the container's port 80.
docker run --rm -d -p 8080:80 --name my-openresty openresty/openresty:bookworm
--rm: Automatically removes the container when it exits.-d: Runs the container in the background.-p 8080:80: Maps port 8080 on the host to port 80 in the container.--name my-openresty: Assigns a convenient name to the container.
Step 3: Verify It's Running
You can now send a request to the server using curl or your web browser.
curl http://localhost:8080
You should see the default Nginx welcome page HTML as a response.
Step 4: Serving Custom Content
To serve your own files, you can use a Docker volume to mount a local directory into the container's web root (/usr/local/openresty/nginx/html).
-
Create a local directory and a sample
index.htmlfile.mkdir -p my-app/html echo "<h1>Hello from Docker OpenResty!</h1>" > my-app/html/index.html -
Stop the previous container.
docker stop my-openresty -
Run a new container, mounting your
my-app/htmldirectory.
Note:docker run --rm -d -p 8080:80 \ -v "$(pwd)/my-app/html:/usr/local/openresty/nginx/html:ro" \ --name my-openresty openresty/openresty:bookworm:romakes the volume read-only inside the container, which is a good security practice. -
Verify again by sending a request.
curl http://localhost:8080This time, you should see your custom message:
<h1>Hello from Docker OpenResty!</h1>.
Next Steps
- Learn how to provide your own Nginx Configuration.
- Explore the different Image Flavors to find the best one for your needs.
- Dive into Building Custom Images to create a tailored OpenResty environment.