0
Look at the error;
It informs that my JAR file gave error and because of this it was not executed;
My file Docker-Compose.yml must be in error, and for lack of experience I am not being able to identify, I need help, this is my file;
version: '3'
services:
kwan:
image: postgres:11.5
network_mode: bridge
container_name: postgres
expose:
- 5432
ports:
- 5432:5432
environment:
- POSTGRES_PASSWORD=root
- POSTGRES_USER=postgres
- POSTGRES_DB=root
restart: unless-stopped
springapi:
image: openjdk:10-jre-slim
container_name: springapi
ports:
- 8080:8080
depends_on:
- kwan
command: ["java", "-jar", "application.jar"]
It is important to inform that my operating system is Windows 10!
This is my briefcase!
I tried that way;
version: '3'
services:
kwan:
image: postgres:11.5
network_mode: bridge
container_name: postgres
expose:
- 5432
ports:
- 5432:5432
environment:
- POSTGRES_PASSWORD=root
- POSTGRES_USER=postgres
- POSTGRES_DB=root
restart: unless-stopped
springapi:
image: openjdk:10-jre-slim
container_name: springapi
ports:
- 8080:8080
depends_on:
- kwan
volumes:
- dockerTest-1.0.0-SNAPSHOT.jar:/application.jar
command: ["java", "-Dspring.profiles.active=docker-demo", "application.jar"]
But it generates this error;
$ docker-compose up
ERROR: Named volume "dockerTest-1.0.0-SNAPSHOT.jar:/application.jar:rw" is used in service "springapi" but no declaration was found in the volumes section.
I too have been like this;
version: '3'
services:
kwan:
image: postgres:11.5
network_mode: bridge
container_name: postgres
expose:
- 5432
ports:
- 5432:5432
environment:
- POSTGRES_PASSWORD=root
- POSTGRES_USER=postgres
- POSTGRES_DB=root
restart: unless-stopped
jar:
image: openjdk:8-jre-slim
volumes:
- ./dockerTest-1.0.0-SNAPSHOT.jar
command: "bash" -c "java -Dspring.profiles.active=docker-demo"
But it caused this error;
$ docker-compose up
ERROR: yaml.parser.ParserError: while parsing a block mapping
in ".\docker-compose.yml", line 18, column 7
expected <block end>, but found '<scalar>'
in ".\docker-compose.yml", line 21, column 23
And your file is called
dockerTest-1.0.0-SNAPSHOT.jar
, where that came fromapplication.jar
?– Woss
I was to create a nickname for the jar, I’m still learning to handle the Docker.
– wladyband
Try to put in the
volumes
something like"./dockerTest-1.0.0-SNAPSHOT.jar:/application.jar"
and in command also put/application.jar
– Woss
gerou erro:

springapi | Error: Could not find or load main class .application.jar
springapi | Caused by: java.lang.ClassNotFoundException: /application/jar
springapi exited with code 1
– wladyband