Fix default port mapping and indentation
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
parent
dc1bb13dce
commit
77c6920a83
@ -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
|
||||
- ./angular:/project
|
||||
- /project/node_modules
|
||||
|
@ -3,7 +3,7 @@ services:
|
||||
web:
|
||||
build: app
|
||||
ports:
|
||||
- 80:80
|
||||
- 80:80
|
||||
db:
|
||||
environment:
|
||||
ACCEPT_EULA: "Y"
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
```
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
## .
|
||||
## ## ## ==
|
||||
|
@ -1,12 +1,10 @@
|
||||
|
||||
version: "3.7"
|
||||
services:
|
||||
frontend:
|
||||
build: frontend
|
||||
ports:
|
||||
- 8080:80
|
||||
- 80:80
|
||||
depends_on:
|
||||
- backend
|
||||
- backend
|
||||
backend:
|
||||
build: backend
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
version: "3.7"
|
||||
services:
|
||||
prometheus:
|
||||
@ -22,4 +21,4 @@ services:
|
||||
volumes:
|
||||
- ./grafana:/etc/grafana/provisioning/datasources
|
||||
volumes:
|
||||
prom_data:
|
||||
prom_data:
|
||||
|
@ -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.
|
||||
|
||||
The backend service container has the port 80 mapped to 8080 on the host.
|
||||
![page](output.jpg)
|
||||
|
||||
|
||||
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
|
||||
|
BIN
react-express-mysql/output.jpg
Normal file
BIN
react-express-mysql/output.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -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
|
||||
|
@ -3,4 +3,4 @@ services:
|
||||
sparkjava:
|
||||
build: sparkjava
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 8080:8080
|
||||
|
@ -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:
|
||||
|
@ -3,7 +3,7 @@ services:
|
||||
web:
|
||||
build: vuejs
|
||||
ports:
|
||||
- 80:8080
|
||||
- 8080:8080
|
||||
volumes:
|
||||
- ./vuejs:/project
|
||||
- /project/node_modules
|
||||
- ./vuejs:/project
|
||||
- /project/node_modules
|
||||
|
Loading…
Reference in New Issue
Block a user