Skip to content

Commit

Permalink
Fix default port mapping and indentation
Browse files Browse the repository at this point in the history
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
  • Loading branch information
Anca Iordache committed Mar 23, 2020
1 parent dc1bb13 commit 77c6920
Show file tree
Hide file tree
Showing 20 changed files with 111 additions and 108 deletions.
10 changes: 5 additions & 5 deletions angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions angular/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
web:
build: angular
ports:
- 80:4200
- 4200:4200
volumes:
- ./angular:/project
- /project/node_modules
- ./angular:/project
- /project/node_modules
2 changes: 1 addition & 1 deletion aspnet-mssql/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
web:
build: app
ports:
- 80:80
- 80:80
db:
environment:
ACCEPT_EULA: "Y"
Expand Down
8 changes: 4 additions & 4 deletions gitea-postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
gitea:
image: gitea/gitea:latest
ports:
- 80:3000
- 3000:3000
...
db:
image: postgres:alpine
Expand All @@ -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

Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions gitea-postgres/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ services:
volumes:
- git_data:/data
ports:
- 80:3000
depends_on:
- db
- 3000:3000
db:
image: postgres:alpine
environment:
Expand Down
4 changes: 2 additions & 2 deletions nginx-flask-mongo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
8 changes: 4 additions & 4 deletions nginx-flask-mongo/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 7 additions & 7 deletions nginx-flask-mysql/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
23 changes: 12 additions & 11 deletions nginx-golang-mysql/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 11 additions & 10 deletions nginx-golang-postgres/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 7 additions & 7 deletions nginx-golang/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
## .
## ## ## ==
Expand Down
6 changes: 2 additions & 4 deletions nginx-golang/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

version: "3.7"
services:
frontend:
build: frontend
ports:
- 8080:80
- 80:80
depends_on:
- backend
- backend
backend:
build: backend

3 changes: 1 addition & 2 deletions prometheus-grafana/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

version: "3.7"
services:
prometheus:
Expand All @@ -22,4 +21,4 @@ services:
volumes:
- ./grafana:/etc/grafana/provisioning/datasources
volumes:
prom_data:
prom_data:
34 changes: 19 additions & 15 deletions react-express-mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
Loading

0 comments on commit 77c6920

Please sign in to comment.