Update SparkJava samples

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
Guillaume Lours
2020-03-17 15:30:49 +01:00
parent fdc1e84d85
commit 3f8a58ef62
9 changed files with 41 additions and 33 deletions

View File

@@ -18,11 +18,11 @@ services:
sparkjava:
build: sparkjava
ports:
- 80:8080
- 8080:8080
```
The compose file defines an application with one service `sparkjava`.
When deploying the application, docker-compose maps port 8080 of the sparkjava service container to port 80 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 8080 of the sparkjava 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.
## Deploy with docker-compose
@@ -30,8 +30,8 @@ Make sure port 80 on the host is not already being in use.
$ docker-compose up -d
Creating network "sparkjava_default" with the default driver
Building sparkjava
Step 1/9 : FROM maven:3.5-jdk-8-alpine AS build
3.5-jdk-8-alpine: Pulling from library/maven
Step 1/11 : FROM maven:3.6.3-jdk-11 AS build
3.6.3-jdk-11: Pulling from library/maven
...
Successfully tagged sparkjava_sparkjava:latest
WARNING: Image for service sparkjava was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
@@ -44,13 +44,13 @@ Listing containers must show two containers running and the port mapping as belo
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5af94cb25394 sparkjava_sparkjava "/bin/sh -c 'java -j…" 20 seconds ago Up 19 seconds 0.0.0.0:80->8080/tcp sparkjava_sparkjava_1
5af94cb25394 sparkjava_sparkjava "/bin/sh -c 'java -j…" 20 seconds ago Up 19 seconds 0.0.0.0:8080->8080/tcp sparkjava_sparkjava_1
```
After the application starts, navigate to `http://localhost:80` in your web browser or run:
After the application starts, navigate to `http://localhost:8080` in your web browser or run:
```
$ curl localhost:80
Hello world
$ curl localhost:8080
Hello from Docker!
```
Stop and remove the containers