Sfoglia il codice sorgente

Merge pull request #27 from aiordache/master

Fix default port mapping and indentation
Anca Iordache 5 anni fa
parent
commit
92ee31c1dd

+ 5 - 5
angular/README.md

@@ -19,14 +19,14 @@ services:
   web:
   web:
     build: angular
     build: angular
     ports:
     ports:
-    - 80:4200
+    - 4200:4200
     ...
     ...
 
 
 ```
 ```
 The compose file defines an application with one service `angular`. The image for the service is built with the Dockerfile inside the `angular` directory (build parameter).
 The compose file defines an application with one service `angular`. The image for the service is built with the Dockerfile inside the `angular` directory (build parameter).
 
 
-When deploying the application, docker-compose maps the container port 4200 to port 80 of the host as specified in the file.
-Make sure port 80 is not being used by another container, otherwise the port should be changed.
+When deploying the application, docker-compose maps the container port 4200 to the same port on the host as specified in the file.
+Make sure port 4200 is not being used by another container, otherwise the port should be changed.
 
 
 
 
 ## Deploy with docker-compose
 ## Deploy with docker-compose
@@ -53,11 +53,11 @@ Listing containers must show a container running and the port mapping as below:
 ```
 ```
 $ docker ps
 $ docker ps
 CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
 CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
-6884c228388e        angular_web         "docker-entrypoint.s…"   42 seconds ago      Up 36 seconds       0.0.0.0:80->4200/tcp   angular_web_1
+6884c228388e        angular_web         "docker-entrypoint.s…"   42 seconds ago      Up 36 seconds       0.0.0.0:4200->4200/tcp angular_web_1
 
 
 ```
 ```
 
 
-After the application starts, navigate to `http://localhost:80` in your web browser.
+After the application starts, navigate to `http://localhost:4200` in your web browser.
 
 
 ![page](output.jpg)
 ![page](output.jpg)
 
 

+ 3 - 3
angular/docker-compose.yaml

@@ -3,7 +3,7 @@ services:
   web:
   web:
     build: angular
     build: angular
     ports:
     ports:
-    - 80:4200
+      - 4200:4200
     volumes:
     volumes:
-    - ./angular:/project
-    - /project/node_modules
+      - ./angular:/project
+      - /project/node_modules

+ 1 - 1
aspnet-mssql/docker-compose.yaml

@@ -3,7 +3,7 @@ services:
   web:
   web:
     build: app
     build: app
     ports:
     ports:
-    - 80:80
+      - 80:80
   db:
   db:
     environment:
     environment:
       ACCEPT_EULA: "Y"
       ACCEPT_EULA: "Y"

+ 4 - 4
gitea-postgres/README.md

@@ -15,7 +15,7 @@ services:
   gitea:
   gitea:
     image: gitea/gitea:latest
     image: gitea/gitea:latest
     ports:
     ports:
-      - 80:3000
+      - 3000:3000
     ...
     ...
   db:
   db:
     image: postgres:alpine
     image: postgres:alpine
@@ -24,7 +24,7 @@ services:
 ```
 ```
 
 
 When deploying this setup, docker-compose maps the nextcloud container port 3000 to
 When deploying this setup, docker-compose maps the nextcloud container port 3000 to
-port 80 of the host as specified in the compose file.
+the same port of the host as specified in the compose file.
 
 
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
@@ -46,11 +46,11 @@ Check containers are running and the port mapping:
 ```
 ```
 $ docker ps
 $ docker ps
 CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                          NAMES
 CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                          NAMES
-2f5624043da9        gitea/gitea:latest   "/usr/bin/entrypoint…"   56 seconds ago      Up 16 seconds       22/tcp, 0.0.0.0:80->3000/tcp   gitea-postgres_gitea_1
+2f5624043da9        gitea/gitea:latest   "/usr/bin/entrypoint…"   56 seconds ago      Up 16 seconds       22/tcp, 0.0.0.0:3000->3000/tcp gitea-postgres_gitea_1
 86acc768453e        postgres:alpine      "docker-entrypoint.s…"   57 seconds ago      Up 17 seconds       5432/tcp                       gitea-postgres_db_1
 86acc768453e        postgres:alpine      "docker-entrypoint.s…"   57 seconds ago      Up 17 seconds       5432/tcp                       gitea-postgres_db_1
 ```
 ```
 
 
-Navigate to `http://localhost:80` in your web browser to access the installed
+Navigate to `http://localhost:3000` in your web browser to access the installed
 Gitea service.
 Gitea service.
 
 
 ![page](output.jpg)
 ![page](output.jpg)

+ 1 - 3
gitea-postgres/docker-compose.yaml

@@ -12,9 +12,7 @@ services:
     volumes:
     volumes:
       - git_data:/data
       - git_data:/data
     ports:
     ports:
-      - 80:3000
-    depends_on: 
-      - db
+      - 3000:3000
   db:
   db:
     image: postgres:alpine
     image: postgres:alpine
     environment:
     environment:

+ 2 - 2
nginx-flask-mongo/README.md

@@ -53,8 +53,8 @@ Creating nginx-flask-mongo_web_1     ... done
 Listing containers must show two containers running and the port mapping as below:
 Listing containers must show two containers running and the port mapping as below:
 ```
 ```
 $ docker ps
 $ docker ps
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
-a0f4ebe686ff        nginx                       "/bin/bash -c 'envsu…"   About a minute ago   Up About a minute   0.0.0.0:8080->80/tcp   nginx-flask-mongo_web_1
+CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                  NAMES
+a0f4ebe686ff        nginx                       "/bin/bash -c 'envsu…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp     nginx-flask-mongo_web_1
 dba87a080821        nginx-flask-mongo_backend   "./server.py"            About a minute ago   Up About a minute                          nginx-flask-mongo_backend_1
 dba87a080821        nginx-flask-mongo_backend   "./server.py"            About a minute ago   Up About a minute                          nginx-flask-mongo_backend_1
 d7eea5481c77        mongo                       "docker-entrypoint.s…"   About a minute ago   Up About a minute   27017/tcp              nginx-flask-mongo_mongo_1
 d7eea5481c77        mongo                       "docker-entrypoint.s…"   About a minute ago   Up About a minute   27017/tcp              nginx-flask-mongo_mongo_1
 ```
 ```

+ 4 - 4
nginx-flask-mongo/docker-compose.yaml

@@ -8,15 +8,15 @@ services:
       - FLASK_SERVER_ADDR=backend:9091  
       - FLASK_SERVER_ADDR=backend:9091  
     command: /bin/bash -c "envsubst < /tmp/nginx.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" 
     command: /bin/bash -c "envsubst < /tmp/nginx.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" 
     ports:
     ports:
-    - 8080:80
+      - 80:80
     depends_on:
     depends_on:
-    - backend
+      - backend
   backend:
   backend:
     build: flask
     build: flask
     environment: 
     environment: 
-    - FLASK_SERVER_PORT=9091
+      - FLASK_SERVER_PORT=9091
     volumes:
     volumes:
-    - ./flask:/src
+      - ./flask:/src
     depends_on:
     depends_on:
       -  mongo  
       -  mongo  
   mongo:
   mongo:

+ 7 - 7
nginx-flask-mysql/docker-compose.yaml

@@ -5,9 +5,9 @@ services:
     command: '--default-authentication-plugin=mysql_native_password'
     command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     secrets:
     secrets:
-    - db-password
+      - db-password
     volumes:
     volumes:
-    - db-data:/var/lib/mysql
+      - db-data:/var/lib/mysql
     networks:
     networks:
       - backnet
       - backnet
     environment:
     environment:
@@ -17,17 +17,17 @@ services:
     build: backend
     build: backend
     restart: always
     restart: always
     secrets:
     secrets:
-    - db-password
+      - db-password
     ports:
     ports:
-    - 5000:5000
+      - 5000:5000
     networks:
     networks:
-    - backnet
-    - frontnet
+      - backnet
+      - frontnet
   proxy:
   proxy:
     build: proxy
     build: proxy
     restart: always
     restart: always
     ports:
     ports:
-    - 80:80
+      - 80:80
     networks:
     networks:
       - frontnet
       - frontnet
 volumes:
 volumes:

+ 12 - 11
nginx-golang-mysql/docker-compose.yaml

@@ -3,27 +3,28 @@ services:
   backend:
   backend:
     build: backend
     build: backend
     secrets:
     secrets:
-    - db-password
+      - db-password
     depends_on: 
     depends_on: 
-    - db
+      - db
   db:
   db:
-    environment:
-      MYSQL_DATABASE: example
-      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password
-    image: mysql:5.7
+    image: mysql:8.0.19
+    command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     secrets:
     secrets:
-    - db-password
+      - db-password
     volumes:
     volumes:
-    - db-data:/var/lib/mysql
+      - db-data:/var/lib/mysql
+    environment:
+      - MYSQL_DATABASE=example
+      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
   proxy:
   proxy:
     build: proxy
     build: proxy
     ports:
     ports:
-    - 80:80
+      - 80:80
     depends_on: 
     depends_on: 
-    - backend
+      - backend
 volumes:
 volumes:
-  db-data: {}
+  db-data:
 secrets:
 secrets:
   db-password:
   db-password:
     file: db/password.txt
     file: db/password.txt

+ 11 - 10
nginx-golang-postgres/docker-compose.yaml

@@ -3,27 +3,28 @@ services:
   backend:
   backend:
     build: backend
     build: backend
     secrets:
     secrets:
-    - db-password
+      - db-password
     depends_on:
     depends_on:
-    - db
+      - db
   db:
   db:
-    environment:
-      POSTGRES_DB: example
-      POSTGRES_PASSWORD_FILE: /run/secrets/db-password
     image: postgres
     image: postgres
     restart: always
     restart: always
     secrets:
     secrets:
-    - db-password
+      - db-password
     volumes:
     volumes:
-    - db-data:/var/lib/postgresql/data
+      - db-data:/var/lib/postgresql/data
+    environment:
+      - POSTGRES_DB=example
+      - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
+    
   proxy:
   proxy:
     build: proxy
     build: proxy
     ports:
     ports:
-    - 80:80
+      - 80:80
     depends_on: 
     depends_on: 
-    - backend
+      - backend
 volumes:
 volumes:
-  db-data: {}
+  db-data:
 secrets:
 secrets:
   db-password:
   db-password:
     file: db/password.txt
     file: db/password.txt

+ 7 - 7
nginx-golang/README.md

@@ -21,13 +21,13 @@ services:
   frontend:
   frontend:
     build: frontend
     build: frontend
     ports:
     ports:
-    - 8080:80
+    - 80:80
   backend:
   backend:
     build: backend
     build: backend
 ```
 ```
 The compose file defines an application with two services `frontend` and `backend`.
 The compose file defines an application with two services `frontend` and `backend`.
-When deploying the application, docker-compose maps port 80 of the frontend service container to port 8080 of the host as specified in the file.
-Make sure port 8080 on the host is not already being in use.
+When deploying the application, docker-compose maps port 80 of the frontend service container to the same port of the host as specified in the file.
+Make sure port 80 on the host is not already being in use.
 
 
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
@@ -50,14 +50,14 @@ Creating nginx-golang_frontend_1 ... done
 Listing containers must show two containers running and the port mapping as below:
 Listing containers must show two containers running and the port mapping as below:
 ```
 ```
 $ docker ps
 $ docker ps
-CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
-8bd5b0d78e73        nginx-golang_frontend   "nginx -g 'daemon of…"   53 seconds ago      Up 52 seconds       0.0.0.0:8080->80/tcp   nginx-golang_frontend_1
+CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                  NAMES
+8bd5b0d78e73        nginx-golang_frontend   "nginx -g 'daemon of…"   53 seconds ago      Up 52 seconds       0.0.0.0:80->80/tcp     nginx-golang_frontend_1
 56f929c240a0        nginx-golang_backend    "/usr/local/bin/back…"   53 seconds ago      Up 53 seconds                              nginx-golang_backend_1
 56f929c240a0        nginx-golang_backend    "/usr/local/bin/back…"   53 seconds ago      Up 53 seconds                              nginx-golang_backend_1
 ```
 ```
 
 
-After the application starts, navigate to `http://localhost:8080` in your web browser or run:
+After the application starts, navigate to `http://localhost:80` in your web browser or run:
 ```
 ```
-$ curl localhost:8080
+$ curl localhost:80
 
 
           ##         .
           ##         .
     ## ## ##        ==
     ## ## ##        ==

+ 2 - 4
nginx-golang/docker-compose.yml

@@ -1,12 +1,10 @@
-
 version: "3.7"
 version: "3.7"
 services:
 services:
   frontend:
   frontend:
     build: frontend    
     build: frontend    
     ports:
     ports:
-    - 8080:80
+      - 80:80
     depends_on:
     depends_on:
-    - backend
+      - backend
   backend:
   backend:
     build: backend
     build: backend
-

+ 1 - 2
prometheus-grafana/docker-compose.yml

@@ -1,4 +1,3 @@
-
 version: "3.7"
 version: "3.7"
 services:
 services:
   prometheus:
   prometheus:
@@ -22,4 +21,4 @@ services:
     volumes:
     volumes:
       - ./grafana:/etc/grafana/provisioning/datasources
       - ./grafana:/etc/grafana/provisioning/datasources
 volumes:
 volumes:
-  prom_data:
+  prom_data:

+ 19 - 15
react-express-mysql/README.md

@@ -21,19 +21,23 @@ Project structure:
 services:
 services:
   backend:
   backend:
     build: backend
     build: backend
+    ports:
+      - 80:80
+      - 9229:9229
+      - 9230:9230
     ...
     ...
   db:
   db:
-    image: mysql:5.7
+    image: mysql:8.0.19
     ...
     ...
   frontend:
   frontend:
     build: frontend
     build: frontend
     ports:
     ports:
-    - 80:9000
+    - 3000:3000
     ...
     ...
 ```
 ```
 The compose file defines an application with three services `frontend`, `backend` and `db`.
 The compose file defines an application with three services `frontend`, `backend` and `db`.
-When deploying the application, docker-compose maps port 80 of the frontend service container to port 9000 of the host as specified in the file.
-Make sure port 80 on the host is not already being in use.
+When deploying the application, docker-compose maps port 3000 of the frontend service container to port 3000 of the host as specified in the file.
+Make sure port 3000 on the host is not already being in use.
 
 
 ## Deploy with docker-compose
 ## Deploy with docker-compose
 
 
@@ -56,21 +60,21 @@ Creating react-express-mysql_frontend_1 ... done
 Listing containers must show containers running and the port mapping as below:
 Listing containers must show containers running and the port mapping as below:
 ```
 ```
 $ docker ps
 $ docker ps
-CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                NAMES
-5e3ecd0289c0        nginx-golang-postgres_proxy     "nginx -g 'daemon of…"   48 seconds ago      Up 48 seconds       0.0.0.0:80->80/tcp   nginx-golang-postgres_proxy_1
-ffa1410b1c8a        nginx-golang-postgres_backend   "/server"                49 seconds ago      Up 48 seconds       8000/tcp             nginx-golang-postgres_backend_1
-e63be7db7cbc        postgres                        "docker-entrypoint.s…"   49 seconds ago      Up 49 seconds       5432/tcp             nginx-golang-postgres_db_1
+CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                   PORTS                                                  NAMES
+f3e1183e709e        react-express-mysql_frontend   "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes             0.0.0.0:3000->3000/tcp                                 react-express-mysql_frontend_1
+9422da53da76        react-express-mysql_backend    "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes (healthy)   0.0.0.0:80->80/tcp, 0.0.0.0:9229-9230->9229-9230/tcp   react-express-mysql_backend_1
+a434bce6d2be        mysql:8.0.19                   "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes             3306/tcp, 33060/tcp                                    react-express-mysql_db_1
 ```
 ```
 
 
-After the application starts, navigate to `http://localhost:80` in your web browser to get a colorful message.
-```
-My New React App
-```
+After the application starts, navigate to `http://localhost:3000` in your web browser.
+
+![page](output.jpg)
+
 
 
-The backend service container has the port 80 mapped to 8080 on the host.
+The backend service container has the port 80 mapped to 80 on the host.
 ```
 ```
-$ curl localhost:8080
-Hello Docker World
+$ curl localhost:80
+{"message":"Hello Docker World!"}
 ```
 ```
 
 
 Stop and remove the containers
 Stop and remove the containers

+ 10 - 9
react-express-mysql/docker-compose.yaml

@@ -9,7 +9,7 @@ services:
     environment:
     environment:
       - NODE_ENV=development
       - NODE_ENV=development
     ports:
     ports:
-      - 8080:80
+      - 80:80
       - 9229:9229
       - 9229:9229
       - 9230:9230
       - 9230:9230
     volumes:
     volumes:
@@ -23,10 +23,8 @@ services:
     depends_on:
     depends_on:
       - db
       - db
   db:
   db:
-    environment:
-      MYSQL_DATABASE: example
-      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password
     image: mysql:8.0.19
     image: mysql:8.0.19
+    command: '--default-authentication-plugin=mysql_native_password'
     restart: always
     restart: always
     secrets:
     secrets:
       - db-password
       - db-password
@@ -34,12 +32,15 @@ services:
       - db-data:/var/lib/mysql
       - db-data:/var/lib/mysql
     networks:
     networks:
       - private
       - private
+    environment:
+      - MYSQL_DATABASE=example
+      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
   frontend:
   frontend:
     build:
     build:
       context: frontend
       context: frontend
       target: development
       target: development
     ports:
     ports:
-      - 9000:3000
+      - 3000:3000
     volumes:
     volumes:
       - ./frontend/src:/code/src
       - ./frontend/src:/code/src
       - /code/node_modules
       - /code/node_modules
@@ -48,11 +49,11 @@ services:
     depends_on:
     depends_on:
       - backend
       - backend
 networks:
 networks:
-  public: {}
-  private: {}
+  public:
+  private:
 volumes:
 volumes:
-  back-notused: {}
-  db-data: {}
+  back-notused:
+  db-data:
 secrets:
 secrets:
   db-password:
   db-password:
     file: db/password.txt
     file: db/password.txt

BIN
react-express-mysql/output.jpg


+ 9 - 8
sparkjava-mysql/docker-compose.yaml

@@ -3,21 +3,22 @@ services:
   backend:
   backend:
     build: backend
     build: backend
     ports:
     ports:
-    - 8080:8080
+      - 8080:8080
     secrets:
     secrets:
-    - db-password
+      - db-password
   db:
   db:
-    environment:
-      MYSQL_DATABASE: example
-      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password
     image: mysql:8.0.19
     image: mysql:8.0.19
     restart: always
     restart: always
     secrets:
     secrets:
-    - db-password
+      - db-password
     volumes:
     volumes:
-    - db-data:/var/lib/mysql
+      - db-data:/var/lib/mysql
+    environment:
+      - MYSQL_DATABASE=example
+      - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
+    
 volumes:
 volumes:
-  db-data: {}
+  db-data:
 secrets:
 secrets:
   db-password:
   db-password:
     file: db/password.txt
     file: db/password.txt

+ 1 - 1
sparkjava/docker-compose.yaml

@@ -3,4 +3,4 @@ services:
   sparkjava:
   sparkjava:
     build: sparkjava
     build: sparkjava
     ports:
     ports:
-    - 8080:8080
+      - 8080:8080

+ 9 - 9
spring-postgres/docker-compose.yaml

@@ -3,27 +3,27 @@ services:
   backend:
   backend:
     build: backend
     build: backend
     ports:
     ports:
-    - 80:8080
+      - 8080:8080
     environment:
     environment:
-      POSTGRES_DB: example
+      - POSTGRES_DB=example
     networks:
     networks:
       - spring-postgres
       - spring-postgres
   db:
   db:
-    environment:
-      POSTGRES_DB: example
-      POSTGRES_PASSWORD_FILE: /run/secrets/db-password
     image: postgres
     image: postgres
     restart: always
     restart: always
     secrets:
     secrets:
-    - db-password
+      - db-password
     volumes:
     volumes:
-    - db-data:/var/lib/postgresql/data
+      - db-data:/var/lib/postgresql/data
     networks:
     networks:
       - spring-postgres
       - spring-postgres
+    environment:
+      - POSTGRES_DB=example
+      - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
 volumes:
 volumes:
-  db-data: {}
+  db-data:
 secrets:
 secrets:
   db-password:
   db-password:
     file: db/password.txt
     file: db/password.txt
 networks:
 networks:
-  spring-postgres: {}
+  spring-postgres:

+ 3 - 3
vuejs/docker-compose.yaml

@@ -3,7 +3,7 @@ services:
   web:
   web:
     build: vuejs
     build: vuejs
     ports:
     ports:
-    - 80:8080
+      - 8080:8080
     volumes:
     volumes:
-    - ./vuejs:/project
-    - /project/node_modules
+      - ./vuejs:/project
+      - /project/node_modules