{"id":18123321,"url":"https://github.com/jay-johnson/docker-nginx","last_synced_at":"2025-04-06T12:45:39.521Z","repository":{"id":72596178,"uuid":"61930496","full_name":"jay-johnson/docker-nginx","owner":"jay-johnson","description":"A configurable docker nginx container running on CentOS 7","archived":false,"fork":false,"pushed_at":"2016-06-25T17:44:25.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T18:50:00.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jay-johnson.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-25T06:37:51.000Z","updated_at":"2016-11-08T22:17:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"a1b5f3c0-bded-4c36-9c57-ea1d88758fe2","html_url":"https://github.com/jay-johnson/docker-nginx","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-nginx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-nginx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-nginx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jay-johnson%2Fdocker-nginx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jay-johnson","download_url":"https://codeload.github.com/jay-johnson/docker-nginx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485253,"owners_count":20946398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-01T07:09:16.231Z","updated_at":"2025-04-06T12:45:39.503Z","avatar_url":"https://github.com/jay-johnson.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"==============\nDocker + Nginx\n==============\n\nThis is a repository_ for hosting a configurable docker + nginx container running on CentOS 7. I use this container for hosting my blog with the sphinx-bootstrap container:\n\nhttp://jaypjohnson.com\n\nDocker Hub Image: `jayjohnson/nginx`_\n\nDate: **2016-06-24**\n\n.. role:: bash(code)\n      :language: bash\n\nOverview\n--------\n\nI built this container so I could have an extensible nginx container that could utilize a mounted volume for static files and ssl certs. By default this container will start by installing the necessary configuration files, install a robots.txt file, and then start a backgrounded nginx process.\n\nEnvironment Variables\n~~~~~~~~~~~~~~~~~~~~~\n\nHere are the available environment variables that are used by the start_container.sh_ script as the container starts up. By using environment variables to drive one-time install/configuration behaviors this container can be used with `docker compose`_ for other technologies that I want to use with nginx. I wrote this `blog post`_ if you want to learn more.\n\n+----------------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------+ \n| Variable Name                          | Purpose                                                            | Default Value                                               | \n+========================================+====================================================================+=============================================================+ \n| **ENV_BASE_NGINX_CONFIG**              | Provide a path to a `base nginx.conf`_                             | /root/containerfiles/base_nginx.conf                        | \n+----------------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------+ \n| **ENV_DERIVED_NGINX_CONFIG**           | Provide a path to a `derived nginx.conf`_                          | /root/containerfiles/derived_nginx.conf                     | \n+----------------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------+ \n| **ENV_DEFAULT_ROOT_VOLUME**            | Path to shared volume for static html, js, css, images, and assets | /usr/share/nginx/html                                       | \n+----------------------------------------+--------------------------------------------------------------------+-------------------------------------------------------------+ \n\n\nGetting Started\n---------------\n\nBy default this container exposes ports: ``80`` and ``443`` from the container to the host OS. For development purposes, I usually have this container using host ports 82 and 444 to prevent collisions with existing apache or nginx services.\n\nBuilding\n~~~~~~~~\n\nTo build the container you can run ``build.sh`` that automatically sources the properties.sh_ file: \n\n::\n\n    $ ./build.sh \n    Building new Docker image(docker.io/jayjohnson/nginx)\n    Sending build context to Docker daemon 37.38 kB\n    Step 1 : FROM centos:7\n     ---\u003e 904d6c400333\n\n    ...\n\n    ---\u003e 8bfb9d8ca828\n    Successfully built 8bfb9d8ca828\n    $\n\nHere is the full the command:\n\n    :code:`docker build --rm -t \u003cyour name\u003e/nginx --build-arg registry=docker.io --build-arg maintainer=\u003cyour name\u003e --build-arg imagename=nginx .`\n\n\nStart the Container\n~~~~~~~~~~~~~~~~~~~\n\nTo start the container run:\n\n::\n\n    $ ./start.sh \n    Starting new Docker image(docker.io/jayjohnson/nginx)\n    ad836abf4f30eb629d501b4c1cf5b9709001293dab4e3e6b886639bd00ab4d33\n    $ \n\nLooking into the start.sh_ you can see that there are quite a few defaults taken from the properties.sh_ file:\n\n::\n\n    $ cat start.sh \n    #!/bin/bash\n\n    source ./properties.sh .\n\n    echo \"Starting new Docker image($registry/$maintainer/$imagename)\"\n    docker run --name=$imagename \\\n                -e ENV_BASE_NGINX_CONFIG=$ENV_BASE_NGINX_CONFIG \\\n                -e ENV_DERIVED_NGINX_CONFIG=$ENV_DERIVED_NGINX_CONFIG \\\n                -e ENV_DEFAULT_ROOT_VOLUME=$ENV_DEFAULT_ROOT_VOLUME \\\n                -v $EXT_MOUNTED_VOLUME:$INT_MOUNTED_VOLUME \\\n                -p 82:80 \\\n                -p 444:443 \\\n                -d $maintainer/$imagename \n\n    exit 0\n    $\n\n\nTest the Container\n~~~~~~~~~~~~~~~~~~\n\nTo test the container is working try wget-ting the index.html file and confirm there is a returned ``200`` response status code:\n\n::\n\n    $ wget http://localhost:82/ \n    --2016-06-24 13:29:38--  http://localhost:82/\n    Resolving localhost (localhost)... 127.0.0.1\n    Connecting to localhost (localhost)|127.0.0.1|:82... connected.\n    HTTP request sent, awaiting response... 200 OK\n    Length: 13534 (13K) [text/html]\n    Saving to: ‘index.html’\n\n    index.html               100%[====================================\u003e]  13.22K  --.-KB/s   in 0s     \n\n    2016-06-24 13:29:38 (264 MB/s) - ‘index.html’ saved [13534/13534]\n    $\n\n.. note:: The example above is using port **82** for development and documentation purposes instead of port **80**\n\n\nStop the Container\n~~~~~~~~~~~~~~~~~~\n\nTo stop the container run:\n\n::\n\n    $ ./stop.sh \n    Stopping Docker image(docker.io/jayjohnson/nginx)\n    nginx\n    $ \n\nOr run the command:\n\n::\n    \n    $ docker stop nginx\n\n\nLicenses\n--------\n\nThis repository is licensed under the MIT License.\n\nThe nginx license: http://nginx.org/LICENSE\n\n\n.. _docker compose: https://docs.docker.com/compose/\n.. _repository: https://github.com/jay-johnson/docker-nginx\n.. _jayjohnson/nginx : https://hub.docker.com/r/jayjohnson/nginx/\n.. _start.sh: https://github.com/jay-johnson/docker-nginx/blob/master/start.sh\n.. _start_container.sh: https://github.com/jay-johnson/docker-nginx/blob/master/containerfiles/start-container.sh\n.. _base nginx.conf: https://github.com/jay-johnson/docker-nginx/blob/master/containerfiles/base_nginx.conf\n.. _derived nginx.conf: https://github.com/jay-johnson/docker-nginx/blob/master/containerfiles/derived_nginx.conf\n.. _properties.sh: https://github.com/jay-johnson/docker-nginx/blob/master/properties.sh\n.. _blog post: http://www.levvel.io/blog-post/a-docker-container-pattern-compose-configuration\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay-johnson%2Fdocker-nginx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjay-johnson%2Fdocker-nginx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjay-johnson%2Fdocker-nginx/lists"}