docker-nginx
Table of Contents
Preface
There are many Docker images for nginx.
This article packages a business nginx into a Docker image.
Choosing the nginx Version
alpine
Alpine is a minimal Linux distribution, with an image size of only 7.73M.
nginx also has an alpine-based version.
This article uses the alpine-based version.
stable
nginx has stable and latest versions. Here we choose the stable version.
slim
After choosing nginx-stable-alpine, there are still slim and perl variants.
Here we choose slim, the minimal variant.

The final version is: nginx:stable-alpine-slim
Dockerfile
The final Dockerfile is as follows:
-
Use the nginx version above
-
Remove the default startup scripts from the image
-
Copy your business nginx folder to /etc/nginx
FROM nginx:stable-alpine-slim
RUN rm -rf /docker-entrypoint.d
RUN rm -rf /etc/nginx
COPY ./nginx /etc/nginx
WORKDIR /etc/nginx
CMD ["nginx", "-g", "daemon off;"]
EXPOSE 80
Adapting for Docker
Migrating from a server-based nginx to a Docker nginx requires a few changes.
Docker run command
Note that you need to map both port 80 and port 443.
docker run -d -p 80:80 -p 443:443 --cpus="2" --memory="200m" --restart="always" --name="insistime-nginx" registry.cn-beijing.aliyuncs.com/insistime/insistime-nginx:$version
Update IP addresses
Change all local IPs in your nginx configs,
such as localhost or 127.0.0.1,
to the server’s internal IP.
Update paths
Update log paths to /var/log/nginx.
Update SSL certificate paths to ensure they are accessible inside the container.
Related Articles
mysql-exporter
Preface: Building a monitoring system with Prometheus + Grafana. This article covers monitoring MySQL. Steps include modifying the MySQL exporter config file, installing MySQL exporter, granting MySQL permissions, modifying the Prometheus config file, and adding a Grafana dashboard.
redis-exporter
Setting up Redis monitoring with Prometheus and Grafana using redis-exporter — installation, Prometheus config, and Grafana dashboard setup.
JumpServer
Preface: JumpServer is a popular open-source bastion host. If you have many servers to manage and need security auditing, JumpServer is a great choice. This article covers installation, configuration, and basic usage.
prometheus+grafana
Setting up a monitoring system with Prometheus and Grafana — covering Prometheus server, node-exporter, Grafana dashboard configuration, and Docker deployment.
Docker Private Registry
Preface After becoming proficient with Docker locally, the next step is to push local Docker images to a remote registry for easy access elsewhere. Common commands The previous section covered common Docker commands, see: https://blog.insistime.com/dockercmds Official Docker Hub Docker offici