diff --git a/angular/README.md b/angular/README.md index db94e60..373c14a 100644 --- a/angular/README.md +++ b/angular/README.md @@ -19,14 +19,14 @@ services: web: build: angular 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). -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 @@ -53,11 +53,11 @@ Listing containers must show a container running and the port mapping as below: ``` $ docker ps 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) diff --git a/angular/docker-compose.yaml b/angular/docker-compose.yaml index fb02ab4..d13efd9 100644 --- a/angular/docker-compose.yaml +++ b/angular/docker-compose.yaml @@ -3,7 +3,7 @@ services: web: build: angular ports: - - 80:4200 + - 4200:4200 volumes: - - ./angular:/project - - /project/node_modules + - ./angular:/project + - /project/node_modules diff --git a/aspnet-mssql/docker-compose.yaml b/aspnet-mssql/docker-compose.yaml index da40f1b..cfb9702 100644 --- a/aspnet-mssql/docker-compose.yaml +++ b/aspnet-mssql/docker-compose.yaml @@ -3,7 +3,7 @@ services: web: build: app ports: - - 80:80 + - 80:80 db: environment: ACCEPT_EULA: "Y" diff --git a/gitea-postgres/README.md b/gitea-postgres/README.md index 7b9c6d6..a5a5374 100644 --- a/gitea-postgres/README.md +++ b/gitea-postgres/README.md @@ -15,7 +15,7 @@ services: gitea: image: gitea/gitea:latest ports: - - 80:3000 + - 3000:3000 ... db: image: postgres:alpine @@ -24,7 +24,7 @@ services: ``` 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 @@ -46,11 +46,11 @@ Check containers are running and the port mapping: ``` $ docker ps 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 ``` -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. ![page](output.jpg) diff --git a/gitea-postgres/docker-compose.yaml b/gitea-postgres/docker-compose.yaml index 5d9d818..56ff0a3 100644 --- a/gitea-postgres/docker-compose.yaml +++ b/gitea-postgres/docker-compose.yaml @@ -12,9 +12,7 @@ services: volumes: - git_data:/data ports: - - 80:3000 - depends_on: - - db + - 3000:3000 db: image: postgres:alpine environment: diff --git a/nginx-flask-mongo/README.md b/nginx-flask-mongo/README.md index 12b07c0..fdb2afb 100644 --- a/nginx-flask-mongo/README.md +++ b/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: ``` $ 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 d7eea5481c77 mongo "docker-entrypoint.s…" About a minute ago Up About a minute 27017/tcp nginx-flask-mongo_mongo_1 ``` diff --git a/nginx-flask-mongo/docker-compose.yaml b/nginx-flask-mongo/docker-compose.yaml index b9cb462..f673c3d 100644 --- a/nginx-flask-mongo/docker-compose.yaml +++ b/nginx-flask-mongo/docker-compose.yaml @@ -8,15 +8,15 @@ services: - FLASK_SERVER_ADDR=backend:9091 command: /bin/bash -c "envsubst < /tmp/nginx.conf > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" ports: - - 8080:80 + - 80:80 depends_on: - - backend + - backend backend: build: flask environment: - - FLASK_SERVER_PORT=9091 + - FLASK_SERVER_PORT=9091 volumes: - - ./flask:/src + - ./flask:/src depends_on: - mongo mongo: diff --git a/nginx-flask-mysql/docker-compose.yaml b/nginx-flask-mysql/docker-compose.yaml index d26721f..3b406ed 100644 --- a/nginx-flask-mysql/docker-compose.yaml +++ b/nginx-flask-mysql/docker-compose.yaml @@ -5,9 +5,9 @@ services: command: '--default-authentication-plugin=mysql_native_password' restart: always secrets: - - db-password + - db-password volumes: - - db-data:/var/lib/mysql + - db-data:/var/lib/mysql networks: - backnet environment: @@ -17,17 +17,17 @@ services: build: backend restart: always secrets: - - db-password + - db-password ports: - - 5000:5000 + - 5000:5000 networks: - - backnet - - frontnet + - backnet + - frontnet proxy: build: proxy restart: always ports: - - 80:80 + - 80:80 networks: - frontnet volumes: diff --git a/nginx-golang-mysql/docker-compose.yaml b/nginx-golang-mysql/docker-compose.yaml index b2aaadf..9423a67 100644 --- a/nginx-golang-mysql/docker-compose.yaml +++ b/nginx-golang-mysql/docker-compose.yaml @@ -3,27 +3,28 @@ services: backend: build: backend secrets: - - db-password + - db-password depends_on: - - 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 secrets: - - db-password + - db-password volumes: - - db-data:/var/lib/mysql + - db-data:/var/lib/mysql + environment: + - MYSQL_DATABASE=example + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password proxy: build: proxy ports: - - 80:80 + - 80:80 depends_on: - - backend + - backend volumes: - db-data: {} + db-data: secrets: db-password: file: db/password.txt diff --git a/nginx-golang-postgres/docker-compose.yaml b/nginx-golang-postgres/docker-compose.yaml index 0d66498..bd5dd42 100644 --- a/nginx-golang-postgres/docker-compose.yaml +++ b/nginx-golang-postgres/docker-compose.yaml @@ -3,27 +3,28 @@ services: backend: build: backend secrets: - - db-password + - db-password depends_on: - - db + - db db: - environment: - POSTGRES_DB: example - POSTGRES_PASSWORD_FILE: /run/secrets/db-password image: postgres restart: always secrets: - - db-password + - db-password 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: build: proxy ports: - - 80:80 + - 80:80 depends_on: - - backend + - backend volumes: - db-data: {} + db-data: secrets: db-password: file: db/password.txt diff --git a/nginx-golang/README.md b/nginx-golang/README.md index 2946f1d..3fff798 100644 --- a/nginx-golang/README.md +++ b/nginx-golang/README.md @@ -21,13 +21,13 @@ services: frontend: build: frontend ports: - - 8080:80 + - 80:80 backend: build: 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 @@ -50,14 +50,14 @@ Creating nginx-golang_frontend_1 ... done Listing containers must show two containers running and the port mapping as below: ``` $ 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 ``` -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 ## . ## ## ## == diff --git a/nginx-golang/docker-compose.yml b/nginx-golang/docker-compose.yml index 177c2ef..c69b486 100644 --- a/nginx-golang/docker-compose.yml +++ b/nginx-golang/docker-compose.yml @@ -1,12 +1,10 @@ - version: "3.7" services: frontend: build: frontend ports: - - 8080:80 + - 80:80 depends_on: - - backend + - backend backend: build: backend - diff --git a/prometheus-grafana/docker-compose.yml b/prometheus-grafana/docker-compose.yml index b7881e8..0978e9c 100644 --- a/prometheus-grafana/docker-compose.yml +++ b/prometheus-grafana/docker-compose.yml @@ -1,4 +1,3 @@ - version: "3.7" services: prometheus: @@ -22,4 +21,4 @@ services: volumes: - ./grafana:/etc/grafana/provisioning/datasources volumes: - prom_data: \ No newline at end of file + prom_data: diff --git a/react-express-mysql/README.md b/react-express-mysql/README.md index f35ac30..0d9f5dc 100644 --- a/react-express-mysql/README.md +++ b/react-express-mysql/README.md @@ -21,19 +21,23 @@ Project structure: services: backend: build: backend + ports: + - 80:80 + - 9229:9229 + - 9230:9230 ... db: - image: mysql:5.7 + image: mysql:8.0.19 ... frontend: build: frontend ports: - - 80:9000 + - 3000:3000 ... ``` 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 @@ -56,21 +60,21 @@ Creating react-express-mysql_frontend_1 ... done Listing containers must show containers running and the port mapping as below: ``` $ 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 diff --git a/react-express-mysql/docker-compose.yaml b/react-express-mysql/docker-compose.yaml index 44cde51..ec7e2c8 100644 --- a/react-express-mysql/docker-compose.yaml +++ b/react-express-mysql/docker-compose.yaml @@ -9,7 +9,7 @@ services: environment: - NODE_ENV=development ports: - - 8080:80 + - 80:80 - 9229:9229 - 9230:9230 volumes: @@ -23,10 +23,8 @@ services: depends_on: - db db: - environment: - MYSQL_DATABASE: example - MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password image: mysql:8.0.19 + command: '--default-authentication-plugin=mysql_native_password' restart: always secrets: - db-password @@ -34,12 +32,15 @@ services: - db-data:/var/lib/mysql networks: - private + environment: + - MYSQL_DATABASE=example + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password frontend: build: context: frontend target: development ports: - - 9000:3000 + - 3000:3000 volumes: - ./frontend/src:/code/src - /code/node_modules @@ -48,11 +49,11 @@ services: depends_on: - backend networks: - public: {} - private: {} + public: + private: volumes: - back-notused: {} - db-data: {} + back-notused: + db-data: secrets: db-password: file: db/password.txt diff --git a/react-express-mysql/output.jpg b/react-express-mysql/output.jpg new file mode 100644 index 0000000..94573c9 Binary files /dev/null and b/react-express-mysql/output.jpg differ diff --git a/sparkjava-mysql/docker-compose.yaml b/sparkjava-mysql/docker-compose.yaml index 92cd6aa..3cdef5c 100644 --- a/sparkjava-mysql/docker-compose.yaml +++ b/sparkjava-mysql/docker-compose.yaml @@ -3,21 +3,22 @@ services: backend: build: backend ports: - - 8080:8080 + - 8080:8080 secrets: - - db-password + - db-password db: - environment: - MYSQL_DATABASE: example - MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password image: mysql:8.0.19 restart: always secrets: - - db-password + - db-password volumes: - - db-data:/var/lib/mysql + - db-data:/var/lib/mysql + environment: + - MYSQL_DATABASE=example + - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password + volumes: - db-data: {} + db-data: secrets: db-password: file: db/password.txt diff --git a/sparkjava/docker-compose.yaml b/sparkjava/docker-compose.yaml index 6bb45ee..974ff61 100644 --- a/sparkjava/docker-compose.yaml +++ b/sparkjava/docker-compose.yaml @@ -3,4 +3,4 @@ services: sparkjava: build: sparkjava ports: - - 8080:8080 + - 8080:8080 diff --git a/spring-postgres/docker-compose.yaml b/spring-postgres/docker-compose.yaml index aa64157..9595e59 100644 --- a/spring-postgres/docker-compose.yaml +++ b/spring-postgres/docker-compose.yaml @@ -3,27 +3,27 @@ services: backend: build: backend ports: - - 80:8080 + - 8080:8080 environment: - POSTGRES_DB: example + - POSTGRES_DB=example networks: - spring-postgres db: - environment: - POSTGRES_DB: example - POSTGRES_PASSWORD_FILE: /run/secrets/db-password image: postgres restart: always secrets: - - db-password + - db-password volumes: - - db-data:/var/lib/postgresql/data + - db-data:/var/lib/postgresql/data networks: - spring-postgres + environment: + - POSTGRES_DB=example + - POSTGRES_PASSWORD_FILE=/run/secrets/db-password volumes: - db-data: {} + db-data: secrets: db-password: file: db/password.txt networks: - spring-postgres: {} + spring-postgres: diff --git a/vuejs/docker-compose.yaml b/vuejs/docker-compose.yaml index 5874758..947e6f5 100644 --- a/vuejs/docker-compose.yaml +++ b/vuejs/docker-compose.yaml @@ -3,7 +3,7 @@ services: web: build: vuejs ports: - - 80:8080 + - 8080:8080 volumes: - - ./vuejs:/project - - /project/node_modules + - ./vuejs:/project + - /project/node_modules