Change port number

Signed-off-by: alain <alain@localhost.localdomain>
This commit is contained in:
alain 2020-04-05 10:21:34 +02:00
parent 58589727ff
commit 5558162ad7

View File

@ -21,14 +21,14 @@ services:
backend: backend:
build: backend build: backend
ports: ports:
- 80:8080 - 8080:8080
db: db:
image: postgres image: postgres
... ...
``` ```
The compose file defines an application with two services `backend` and `db`. The compose file defines an application with two services `backend` and `db`.
When deploying the application, docker-compose maps port 8080 of the backend service container to port 80 of the host as specified in the file. When deploying the application, docker-compose maps port 8080 of the backend service container to port 8080 of the host as specified in the file.
Make sure port 80 on the host is not already being in use. Make sure port 8080 on the host is not already being in use.
## Deploy with docker-compose ## Deploy with docker-compose
@ -52,12 +52,12 @@ Listing containers must show two containers running and the port mapping as belo
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
56236f640eaa postgres "docker-entrypoint.s…" 29 seconds ago Up 28 seconds 5432/tcp spring-postgres_db_1 56236f640eaa postgres "docker-entrypoint.s…" 29 seconds ago Up 28 seconds 5432/tcp spring-postgres_db_1
6e69472dc2c0 spring-postgres_backend "java -Djava.securit…" 29 seconds ago Up 28 seconds 0.0.0.0:80->8080/tcp spring-postgres_backend_1 6e69472dc2c0 spring-postgres_backend "java -Djava.securit…" 29 seconds ago Up 28 seconds 0.0.0.0:8080->8080/tcp spring-postgres_backend_1
``` ```
After the application starts, navigate to `http://localhost:80` in your web browse or run: After the application starts, navigate to `http://localhost:8080` in your web browse or run:
``` ```
$ curl localhost:80 $ curl localhost:8080
<!DOCTYPE HTML> <!DOCTYPE HTML>
<html> <html>
<head> <head>