Tengine is a web server originated by Taobao, the largest e-commerce website in Asia. It is based on the Nginx HTTP server and has many advanced features. Tengine has proven to be very stable and efficient on some of the top 100 websites in the world, including taobao.com and tmall.com.
Tengine has been an open source project since December 2011. It is being actively developed by the Tengine team, whose core members are from Taobao, Sogou and other Internet companies. Tengine is a community effort and everyone is encouraged to get involved.
$ docker run --name nginx -v /some/content:/usr/local/nginx/html:ro -d chasontang/tengine:2.1.2_f
Alternatively, a simple Dockerfile can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount above):
FROM chasontang/tengine:2.1.2_f
COPY static-html-directory /usr/local/nginx/html
Place this file in the same directory as your directory of content ("static-html-directory"), run docker build -t some-content-nginx ., then start your container:
$ docker run --name nginx -d some-content-nginx
$ docker run --name nginx -d -p 8080:80 some-content-nginx
Then you can hit http://localhost:8080 or http://host-ip:8080 in your browser.
$ docker run --name some-nginx -v /some/nginx.conf:/etc/nginx/nginx.conf:ro -d chsontang/tengine:2.1.2_f
For information on the syntax of the Nginx configuration files, see the official documentation (specifically the Beginner's Guide).
Be sure to include daemon off; in your custom configuration to ensure that Nginx stays in the foreground so that Docker can track the process properly (otherwise your container will stop immediately after starting)!
If you wish to adapt the default configuration, use something like the following to copy it from a running Nginx container:
$ docker cp some-nginx:/etc/nginx/nginx.conf /some/nginx.conf
As above, this can also be accomplished more cleanly using a simple Dockerfile:
FROM chasontang/tengine:2.1.2_f
COPY nginx.conf /etc/nginx/nginx.conf
Then, build with docker build -t some-custom-nginx . and run:
$ docker run --name some-nginx -d some-custom-nginx
Out-of-the-box, Nginx doesn't support using environment variables inside most configuration blocks. But envsubst may be used as a workaround if you need to generate your nginx configuration dynamically before nginx starts.
Here is an example using docker-compose.yml:
image: chasontang/tengine:2.1.2_f
volumes:
- ./mysite.template:/etc/nginx/conf.d/mysite.template
ports:
- "8080:80"
environment:
- NGINX_HOST=foobar.com
- NGINX_PORT=80
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
The mysite.template file may then contain variable references like this :
listen ${NGINX_PORT};
Content type
Image
Digest
Size
3.4 MB
Last updated
about 10 years ago
docker pull chasontang/tengine:2.1.2