Browse Source

First commit: basic intro, create a custom Nginx images using a Dockerfile.

Frederic G. MARAND 6 years ago
commit
43bf980d17
3 changed files with 58 additions and 0 deletions
  1. 14 0
      Dockerfile
  2. 33 0
      README.md
  3. 11 0
      nginx/html/page.html

+ 14 - 0
Dockerfile

@@ -0,0 +1,14 @@
+# The image to use
+FROM nginx:latest
+
+# The internal port number
+EXPOSE 80
+
+RUN apt-get update && apt-get install -y vim
+
+# Just information for container users
+LABEL maintainer="Frederic G. MARAND <fgm@osinet.fr>"
+
+# Does NOT create the volume, but tips the use that they probably want to map this.
+VOLUME /usr/share/nginx/html
+

+ 33 - 0
README.md

@@ -0,0 +1,33 @@
+From https://www.codeschool.com/screencasts/build-a-node-app-with-postgres-and-docker
+
+* Run nginx 
+  * in foreground
+    * `docker run -p 81:80 --name web nginx`
+  * in foreground and removing it when stopped
+    * `docker run -p 81:80 --name web --rm nginx`
+  * in background
+    * `docker run -p 81:80 --name web -d nginx`
+  * foreground, mounting the nginx/html directory:
+
+        docker run --rm \
+          -p 81:80  \
+          --name web \
+          --mount type=bind,source=$PWD/nginx/html,target=/usr/share/nginx/html \
+          nginx
+* Enter the container:
+
+      docker exec -it web /bin/bash
+* Build a local image from the `Dockerfile`
+
+      docker build -t osinet/nginx:latest .
+* Run the newly built image:
+
+      docker run --rm \
+        -p 81:80 \
+        --name web \
+        --mount type=bind,source=$PWD/nginx/html,target=/usr/share/nginx/html \ 
+        osinet/nginx
+* List images
+  * All except intermediates: `docker images`
+  * All including intermediates: `docker images -a`
+  * Images with this name: `docker images osinet/nginx`

+ 11 - 0
nginx/html/page.html

@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+  </head>
+  <body>
+    <h1>Hello world</h1>
+    <p>This file is coming from a volume.</p>
+  </body>
+</html>