Merge pull request #27 from aiordache/master

Fix default port mapping and indentation
master
Anca Iordache 5 years ago committed by GitHub
commit 92ee31c1dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)

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

@ -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)

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

@ -54,7 +54,7 @@ Listing containers must show two containers running and the port mapping as belo
```
$ 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
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
```

@ -8,7 +8,7 @@ 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:

@ -7,15 +7,16 @@ services:
depends_on:
- 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
volumes:
- db-data:/var/lib/mysql
environment:
- MYSQL_DATABASE=example
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
proxy:
build: proxy
ports:
@ -23,7 +24,7 @@ services:
depends_on:
- backend
volumes:
db-data: {}
db-data:
secrets:
db-password:
file: db/password.txt

@ -7,15 +7,16 @@ services:
depends_on:
- db
db:
environment:
POSTGRES_DB: example
POSTGRES_PASSWORD_FILE: /run/secrets/db-password
image: postgres
restart: always
secrets:
- db-password
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=example
- POSTGRES_PASSWORD_FILE=/run/secrets/db-password
proxy:
build: proxy
ports:
@ -23,7 +24,7 @@ services:
depends_on:
- backend
volumes:
db-data: {}
db-data:
secrets:
db-password:
file: db/password.txt

@ -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
@ -51,13 +51,13 @@ Listing containers must show two containers running and the port mapping as belo
```
$ 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
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
## .
## ## ## ==

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

@ -1,4 +1,3 @@
version: "3.7"
services:
prometheus:

@ -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
@ -57,20 +61,20 @@ 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
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

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

@ -7,17 +7,18 @@ services:
secrets:
- 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
volumes:
- 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

@ -3,15 +3,12 @@ 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:
@ -20,10 +17,13 @@ services:
- 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:

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

Loading…
Cancel
Save