squeakywheel/nginx

By squeakywheel

Updated over 4 years ago

Image

334

Nginx | Ubuntu

About Nginx

Nginx ("engine X") is a high-performance web and reverse proxy server created by Igor Sysoev. It can be used both as a standalone web server and as a proxy to reduce the load on back-end HTTP or mail servers. Read more on the nginx website.

Tags

  • 1.18.0-focal, 1.18.0, 1.18-focal, 1.18, 1-focal, 1, focal, beta - /!\ this is a beta release

Architectures supported

  • amd64, arm64, ppc64el, s390x

Usage

Docker CLI
$ docker run -d --name nginx -p 8080:80 -e TZ=UTC squeakywheel/nginx:edge

You can now point your browser to http://localhost:8080/ and verify that it works.

Parameters

ParameterDescription
-e TZ=UTCTimezone.
-p 8080:80Expose Nginx on localhost:8080.
-v /path/to/website:/var/www/htmlMount and serve a local website.
-v /path/to/conf.template:/etc/nginx/templates/conf.templateMount template files inside /etc/nginx/templates. They will be processed and the results will be placed at /etc/nginx/conf.d. (e.g. listen ${NGINX_PORT}; will generate listen 80;).
-v /my/config/nginx.conf:/etc/nginx/nginx.confMount a local configuration nginx.conf (download this example file).

Testing/Debugging

In case you need to debug what it is happening with the container you can run docker logs <name_of_the_container>. To get access to an interactive shell run:

$ docker exec -it <name_of_the_container> /bin/bash
Deploy with Kubernetes

You can use your favorite Kubernetes distribution; if you don't have one, consider installing MicroK8s.

With microk8s running, enable the dns and storage add-ons:

$ microk8s enable dns storage
$ microk8s kubectl create configmap nginx-config --from-file=nginx=config/nginx.conf

Use the sample deployment yaml provided here. You will also need to download the contents of the html directory here

Apply the `nginx-deployment.yml` (click to expand)
# nginx-deployment.yml
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: squeakywheel/nginx:edge
        volumeMounts:
        - name: nginx-config-volume
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
        - name: nginx-config-volume
          mountPath: /srv/www/index.html
          subPath: index.html
        ports:
        - containerPort: 80
          name: nginx
          protocol: TCP
      volumes:
        - name: nginx-config-volume
          configMap:
            name: nginx-config
            items:
            - key: nginx
              path: nginx.conf
            - key: nginx-site
              path: index.html
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  type: NodePort
  selector:
    app: nginx
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    nodePort: 31080
    name: nginx
$ microk8s kubectl apply -f nginx-deployment.yml

Bugs and Features request

If you find a bug in our image or want to request a specific feature file a bug here:

https://bugs.launchpad.net/ubuntu-docker-images/+filebug

In the title of the bug add nginx: <reason>.

Make sure to include:

  • The digest of the image you are using, you can find it using this command replacing <tag> with the one you used to run the image:
$ docker images --no-trunc --quiet squeakywheel/nginx:<tag>
  • Reproduction steps for the deployment
  • If it is a feature request, please provide as much detail as possible

Docker Pull Command

docker pull squeakywheel/nginx