{"id":13490542,"url":"https://github.com/GoogleCloudPlatform/nginx-docker","last_synced_at":"2025-03-28T06:31:34.572Z","repository":{"id":20458171,"uuid":"89735584","full_name":"GoogleCloudPlatform/nginx-docker","owner":"GoogleCloudPlatform","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-17T12:06:33.000Z","size":5062,"stargazers_count":40,"open_issues_count":1,"forks_count":34,"subscribers_count":28,"default_branch":"master","last_synced_at":"2024-12-18T08:41:09.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleCloudPlatform.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-28T18:50:49.000Z","updated_at":"2024-12-17T12:06:35.000Z","dependencies_parsed_at":"2024-05-31T09:42:49.906Z","dependency_job_id":"3653b5c1-ff3f-48f2-a4af-f77cf627f45e","html_url":"https://github.com/GoogleCloudPlatform/nginx-docker","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/GoogleCloudPlatform%2Fnginx-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fnginx-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fnginx-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleCloudPlatform%2Fnginx-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleCloudPlatform","download_url":"https://codeload.github.com/GoogleCloudPlatform/nginx-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245984564,"owners_count":20704792,"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-07-31T19:00:48.324Z","updated_at":"2025-03-28T06:31:32.391Z","avatar_url":"https://github.com/GoogleCloudPlatform.png","language":"Dockerfile","funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"nginx-docker\n============\n\nDockerfile source for nginx [docker](https://docker.io) image.\n\n# Upstream\nThis source repo was originally copied from:\nhttps://github.com/nginxinc/docker-nginx\n\n# Disclaimer\nThis is not an official Google product.\n\n# \u003ca name=\"about\"\u003e\u003c/a\u003eAbout\n\nThis image contains an installation Nginx 1.x.\n\nFor more information, see the\n[Official Image Marketplace Page](https://console.cloud.google.com/marketplace/details/google/nginx1).\n\nPull command (first install [gcloud](https://cloud.google.com/sdk/downloads)):\n\n```shell\ngcloud auth configure-docker \u0026\u0026 docker -- pull marketplace.gcr.io/google/nginx1\n```\n\nDockerfile for this image can be found [here](https://github.com/GoogleCloudPlatform/nginx-docker/tree/master/1).\n\n# \u003ca name=\"table-of-contents\"\u003e\u003c/a\u003eTable of Contents\n* [Using Kubernetes](#using-kubernetes)\n  * [Running Nginx](#running-nginx-kubernetes)\n    * [Start a Nginx web server](#start-a-nginx-web-server-kubernetes)\n    * [Use a persistent data volume](#use-a-persistent-data-volume-kubernetes)\n  * [Web server configuration](#configuration-kubernetes)\n    * [Viewing existing configuration](#viewing-existing-configuration-kubernetes)\n    * [Using configuration volume](#using-configuration-volume-kubernetes)\n    * [Moving the web content to Nginx](#move-web-content-kubernetes)\n  * [Testing the web server](#testing-the-web-server-kubernetes)\n    * [Accessing the web server from within the container](#accessing-the-web-server-from-within-the-container-kubernetes)\n* [Using Docker](#using-docker)\n  * [Running Nginx](#running-nginx-docker)\n    * [Start a Nginx web server](#start-a-nginx-web-server-docker)\n    * [Use a persistent data volume](#use-a-persistent-data-volume-docker)\n  * [Web server configuration](#configuration-docker)\n    * [Viewing existing configuration](#viewing-existing-configuration-docker)\n    * [Using configuration volume](#using-configuration-volume-docker)\n    * [Moving the web content to Nginx](#move-web-content-docker)\n  * [Testing the web server](#testing-the-web-server-docker)\n    * [Accessing the web server from within the container](#accessing-the-web-server-from-within-the-container-docker)\n* [References](#references)\n  * [Ports](#references-ports)\n  * [Volumes](#references-volumes)\n\n# \u003ca name=\"using-kubernetes\"\u003e\u003c/a\u003eUsing Kubernetes\n\nConsult [Marketplace container documentation](https://cloud.google.com/marketplace/docs/container-images)\nfor additional information about setting up your Kubernetes environment.\n\n## \u003ca name=\"running-nginx-kubernetes\"\u003e\u003c/a\u003eRunning Nginx\n\n### \u003ca name=\"start-a-nginx-web-server-kubernetes\"\u003e\u003c/a\u003eStart a Nginx web server\n\nCopy the following content to `pod.yaml` file, and run `kubectl create -f pod.yaml`.\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: some-nginx\n  labels:\n    name: some-nginx\nspec:\n  containers:\n    - image: marketplace.gcr.io/google/nginx1\n      name: nginx\n```\n\nRun the following to expose the ports.\nDepending on your cluster setup, this might expose your service to the\nInternet with an external IP address. For more information, consult\n[Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/).\n\n```shell\nkubectl expose pod some-nginx --name some-nginx-80 \\\n  --type LoadBalancer --port 80 --protocol TCP\nkubectl expose pod some-nginx --name some-nginx-443 \\\n  --type LoadBalancer --port 443 --protocol TCP\n```\n\nFor information about how to retain your data across restarts, see [Use a persistent data volume](#use-a-persistent-data-volume-kubernetes).\n\nFor information about how to configure your web server, see [Web server configuration](#configuration-kubernetes).\n\n### \u003ca name=\"use-a-persistent-data-volume-kubernetes\"\u003e\u003c/a\u003eUse a persistent data volume\n\nTo preserve your web server data when the container restarts, put\nthe web content directory on a persistent volume.\n\nBy default, `/usr/share/nginx/html` directory on the container houses all the web content files.\n\nCopy the following content to `pod.yaml` file, and run `kubectl create -f pod.yaml`.\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: some-nginx\n  labels:\n    name: some-nginx\nspec:\n  containers:\n    - image: marketplace.gcr.io/google/nginx1\n      name: nginx\n      volumeMounts:\n        - name: webcontent\n          mountPath: /usr/share/nginx/html\n  volumes:\n    - name: webcontent\n      persistentVolumeClaim:\n        claimName: webcontent\n---\n# Request a persistent volume from the cluster using a Persistent Volume Claim.\nkind: PersistentVolumeClaim\napiVersion: v1\nmetadata:\n  name: webcontent\n  annotations:\n    volume.alpha.kubernetes.io/storage-class: default\nspec:\n  accessModes: [ReadWriteOnce]\n  resources:\n    requests:\n      storage: 5Gi\n```\n\nRun the following to expose the ports.\nDepending on your cluster setup, this might expose your service to the\nInternet with an external IP address. For more information, consult\n[Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/).\n\n```shell\nkubectl expose pod some-nginx --name some-nginx-80 \\\n  --type LoadBalancer --port 80 --protocol TCP\nkubectl expose pod some-nginx --name some-nginx-443 \\\n  --type LoadBalancer --port 443 --protocol TCP\n```\n\nThe web server configuration should also be on a persistent volume. For more information, see [Web server configuration](#configuration-kubernetes).\n\n## \u003ca name=\"configuration-kubernetes\"\u003e\u003c/a\u003eWeb server configuration\n\n### \u003ca name=\"viewing-existing-configuration-kubernetes\"\u003e\u003c/a\u003eViewing existing configuration\n\nNginx configuration file is at `/etc/nginx/nginx.conf`.\n\n```shell\nkubectl exec some-nginx -- cat /etc/nginx/nginx.conf\n```\n\n### \u003ca name=\"using-configuration-volume-kubernetes\"\u003e\u003c/a\u003eUsing configuration volume\n\nThe default `nginx.conf` includes all configuration files under `/etc/nginx/conf.d` directory. If you have a `/path/to/your/site.conf` file locally, you can start the server as followed to mount it under `conf.d` directory.\n\nCreate the following `configmap`:\n\n```shell\nkubectl create configmap site-conf \\\n  --from-file=/path/to/your/site.conf\n```\n\nCopy the following content to `pod.yaml` file, and run `kubectl create -f pod.yaml`.\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  name: some-nginx\n  labels:\n    name: some-nginx\nspec:\n  containers:\n    - image: marketplace.gcr.io/google/nginx1\n      name: nginx\n      volumeMounts:\n        - name: site-conf\n          mountPath: /etc/nginx/conf.d\n  volumes:\n    - name: site-conf\n      configMap:\n        name: site-conf\n```\n\nRun the following to expose the ports.\nDepending on your cluster setup, this might expose your service to the\nInternet with an external IP address. For more information, consult\n[Kubernetes documentation](https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/).\n\n```shell\nkubectl expose pod some-nginx --name some-nginx-80 \\\n  --type LoadBalancer --port 80 --protocol TCP\nkubectl expose pod some-nginx --name some-nginx-443 \\\n  --type LoadBalancer --port 443 --protocol TCP\n```\n\n### \u003ca name=\"move-web-content-kubernetes\"\u003e\u003c/a\u003eMoving the web content to Nginx\n\nWe can move the web content to the container with the commands below, assuming `/usr/share/nginx/html` is where nginx has been configured to read from.\n\nCreate the directory if it does not exist yet.\n\n```shell\nkubectl exec some-nginx -- mkdir -p /usr/share/nginx/html\n```\n\nCopy the `index.html` file.\n\n```shell\nkubectl cp /path/to/your/index.html some-nginx:/usr/share/nginx/html/index.html\n```\n\nFollow instructions in [Testing the web server](#testing-the-web-server-kubernetes), you should get back the content of your `index.html`.\n\n## \u003ca name=\"testing-the-web-server-kubernetes\"\u003e\u003c/a\u003eTesting the web server\n\n### \u003ca name=\"accessing-the-web-server-from-within-the-container-kubernetes\"\u003e\u003c/a\u003eAccessing the web server from within the container\n\nAttach to the webserver.\n\n```shell\nkubectl exec -it some-nginx -- bash\n```\n\nInstall `curl`.\n\n```\napt-get update \u0026\u0026 apt-get install -y curl\n```\n\nWe can now use `curl` to see if the webserver returns content.\n\n```\ncurl http://localhost\n```\n\n# \u003ca name=\"using-docker\"\u003e\u003c/a\u003eUsing Docker\n\nConsult [Marketplace container documentation](https://cloud.google.com/marketplace/docs/container-images)\nfor additional information about setting up your Docker environment.\n\n## \u003ca name=\"running-nginx-docker\"\u003e\u003c/a\u003eRunning Nginx\n\n### \u003ca name=\"start-a-nginx-web-server-docker\"\u003e\u003c/a\u003eStart a Nginx web server\n\nUse the following content for the `docker-compose.yml` file, then run `docker-compose up`.\n\n```yaml\nversion: '2'\nservices:\n  nginx:\n    container_name: some-nginx\n    image: marketplace.gcr.io/google/nginx1\n    ports:\n      - '80:80'\n      - '443:443'\n```\n\nOr you can use `docker run` directly:\n\n```shell\ndocker run \\\n  --name some-nginx \\\n  -p 80:80 \\\n  -p 443:443 \\\n  -d \\\n  marketplace.gcr.io/google/nginx1\n```\n\nFor information about how to retain your data across restarts, see [Use a persistent data volume](#use-a-persistent-data-volume-docker).\n\nFor information about how to configure your web server, see [Web server configuration](#configuration-docker).\n\n### \u003ca name=\"use-a-persistent-data-volume-docker\"\u003e\u003c/a\u003eUse a persistent data volume\n\nTo preserve your web server data when the container restarts, put\nthe web content directory on a persistent volume.\n\nBy default, `/usr/share/nginx/html` directory on the container houses all the web content files.\n\nAlso assume that `/my/persistent/dir/www` is the persistent directory on the host.\n\nUse the following content for the `docker-compose.yml` file, then run `docker-compose up`.\n\n```yaml\nversion: '2'\nservices:\n  nginx:\n    container_name: some-nginx\n    image: marketplace.gcr.io/google/nginx1\n    ports:\n      - '80:80'\n      - '443:443'\n    volumes:\n      - /my/persistent/dir/www:/usr/share/nginx/html\n```\n\nOr you can use `docker run` directly:\n\n```shell\ndocker run \\\n  --name some-nginx \\\n  -p 80:80 \\\n  -p 443:443 \\\n  -v /my/persistent/dir/www:/usr/share/nginx/html \\\n  -d \\\n  marketplace.gcr.io/google/nginx1\n```\n\nThe web server configuration should also be on a persistent volume. For more information, see [Web server configuration](#configuration-docker).\n\n## \u003ca name=\"configuration-docker\"\u003e\u003c/a\u003eWeb server configuration\n\n### \u003ca name=\"viewing-existing-configuration-docker\"\u003e\u003c/a\u003eViewing existing configuration\n\nNginx configuration file is at `/etc/nginx/nginx.conf`.\n\n```shell\ndocker exec some-nginx cat /etc/nginx/nginx.conf\n```\n\n### \u003ca name=\"using-configuration-volume-docker\"\u003e\u003c/a\u003eUsing configuration volume\n\nThe default `nginx.conf` includes all configuration files under `/etc/nginx/conf.d` directory. If you have a `/path/to/your/site.conf` file locally, you can start the server as followed to mount it under `conf.d` directory.\n\nUse the following content for the `docker-compose.yml` file, then run `docker-compose up`.\n\n```yaml\nversion: '2'\nservices:\n  nginx:\n    container_name: some-nginx\n    image: marketplace.gcr.io/google/nginx1\n    ports:\n      - '80:80'\n      - '443:443'\n    volumes:\n      - /path/to/your/site.conf:/etc/nginx/conf.d/site.conf\n```\n\nOr you can use `docker run` directly:\n\n```shell\ndocker run \\\n  --name some-nginx \\\n  -p 80:80 \\\n  -p 443:443 \\\n  -v /path/to/your/site.conf:/etc/nginx/conf.d/site.conf \\\n  -d \\\n  marketplace.gcr.io/google/nginx1\n```\n\n### \u003ca name=\"move-web-content-docker\"\u003e\u003c/a\u003eMoving the web content to Nginx\n\nWe can move the web content to the container with the commands below, assuming `/usr/share/nginx/html` is where nginx has been configured to read from.\n\nCreate the directory if it does not exist yet.\n\n```shell\ndocker exec some-nginx mkdir -p /usr/share/nginx/html\n```\n\nCopy the `index.html` file.\n\n```shell\ndocker cp /path/to/your/index.html some-nginx:/usr/share/nginx/html/index.html\n```\n\nFollow instructions in [Testing the web server](#testing-the-web-server-docker), you should get back the content of your `index.html`.\n\n## \u003ca name=\"testing-the-web-server-docker\"\u003e\u003c/a\u003eTesting the web server\n\n### \u003ca name=\"accessing-the-web-server-from-within-the-container-docker\"\u003e\u003c/a\u003eAccessing the web server from within the container\n\nAttach to the webserver.\n\n```shell\ndocker exec -it some-nginx bash\n```\n\nInstall `curl`.\n\n```\napt-get update \u0026\u0026 apt-get install -y curl\n```\n\nWe can now use `curl` to see if the webserver returns content.\n\n```\ncurl http://localhost\n```\n\n# \u003ca name=\"references\"\u003e\u003c/a\u003eReferences\n\n## \u003ca name=\"references-ports\"\u003e\u003c/a\u003ePorts\n\nThese are the ports exposed by the container image.\n\n| **Port** | **Description** |\n|:---------|:----------------|\n| TCP 80 | Nginx http default port |\n| TCP 443 | Nginx https secure connection over SSL |\n| TCP 9113 | Prometheus metrics exporter |\n\n## \u003ca name=\"references-volumes\"\u003e\u003c/a\u003eVolumes\n\nThese are the filesystem paths used by the container image.\n\n| **Path** | **Description** |\n|:---------|:----------------|\n| /etc/nginx | Contains nginx configuration files, including `nginx.conf`. \u003cbr\u003e\u003cbr\u003e The default `nginx.conf` include all `.conf` files under the subdirectory `conf.d`. |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleCloudPlatform%2Fnginx-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGoogleCloudPlatform%2Fnginx-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleCloudPlatform%2Fnginx-docker/lists"}