Sign inSign up

xqdocker/ubuntu-nginx

By xqdocker

Updated over 9 years ago

nginx base on ubuntu system.

Image
6

50K+

xqdocker/ubuntu-nginx repository overview

Ubuntu Nginx

A simple config for nginx on ubuntu system.

Ubuntu 14.04 Nginx 1.10.1 License MIT Docker Pulls Docker Stars Docker image

How to use this image

There are some methods to use this image.

Launch a nginx container with a simple command.
  1. Launch a container with default setting.
$ docker run --name [my-nginx] -d xqdocker/ubuntu-nginx
  1. Launch a container with static content.
$ docker run --name [my-nginx] -v /my/static/content:/data/www -d xqdocker/ubuntu-nginx
  1. Launch a container and exposing the port.
$ docker run --name [my-nginx] -p 8080:80 -d xqdocker/ubuntu-nginx

Then you can access http://localhost:8080 or http://host-ip:8080 in your browser.

  1. Launch a container with config file.
$ docker run --name [my-nginx] -v /my/nginx.conf:/etc/nginx/nginx.conf:ro -d xqdocker/ubuntu-nginx

:ro It's define this directory is read-only in container.

Launch a nginx container with Dockerfile.
  • Step one: Create a simple Dockerfile like the following:

    FROM xqdocker/ubuntu-nginx
    
    COPY /my/static/content /data/www
    COPY /my/nginx.conf /etc/nginx/nginx.conf
    COPY /my/conf.d/default.conf /etc/nginx/conf.d/default.conf
    
  • Step two: Build the docker image with this Dockerfile.

    $ docker build -t [my-ubuntu-nginx] .
    
  • Run the docker image with the following command:

    $ docker run --name [my-nginx] -d [my-ubuntu-nginx]
    
Launch a nginx container with Docker-Compose
  • Step one: Create a simple docker-compose.yml file:

    my-nginx:
      image: ubuntu-nginx
      volumes:
        - /my/static/content:/data/www
        - /my/nginx.conf:/etc/nginx/nginx.conf
        - /my/conf.d/default.conf:/etc/nginx/conf.d/default.conf
      ports:
        - "8080:80"
      environment:
        - NGINX_HOST=example.com
        - NGINX_PORT=80
      command: /bin/bash -c "nginx -g 'daemon off;'"
    
  • Step two: Build and run this docker-compose.yml with Docker-Compose command.

    $ docker-compose run my-nginx
    

Reference

License

Code is under the MIT license.

Tag summary

Content type

Image

Digest

Size

83.5 MB

Last updated

over 9 years ago

docker pull xqdocker/ubuntu-nginx