I'm trying to run two web services in 2 separate containers, but unable to run them both at the same time. Separately they both work.
My project structure is this:
/
- docker-compose.yml
- Dockerfile
- pom.xml
- src/
- ... other spring boot web service folders and files
- Pirmas/
-Dockerfile
-app.py
-docker-compose.yml (it is not used when running both services)
One web service is in the main directory the other is in the directory "Pirmas". I try to run docker composer from the base folder where the spring boot service is. I use the command "docker-compose up --build -d".
However, after building only the spring boot web service is launched and when I check the logs of the flask web service it says "python: can't open file 'app.py': [Errno 2] No such file or directory"
My spring boot service Dockerfile:
FROM maven:3.6-jdk-8 AS build
WORKDIR /code
COPY src /code/app/src
COPY pom.xml /code/app
RUN mvn -f /code/app/pom.xml clean install
FROM openjdk:8
COPY --from=build /code/app/target/SpringWebServiceToDoList-0.0.1-SNAPSHOT.jar SpringWebServiceToDoList-0.0.1-SNAPSHOT.jar
EXPOSE 5000
CMD ["java","-jar","SpringWebServiceToDoList-0.0.1-SNAPSHOT.jar"]
My docker-compose.yml file in the same directory:
version: '3'
services:
springboot-docker-compose-app-container:
build: .
ports:
- "80:5000"
depends_on:
- friendservice
volumes:
- .:/code
networks:
- mynet
friendservice:
build: ./Pirmas
command: python app.py
ports:
- 5000:5001
networks:
- mynet
networks:
mynet:
My Dockerfile in the flash web service:
FROM python:3
WORKDIR /code
COPY requirements.txt ./
RUN pip install -r requirements.txt
Lastly the docker-compose.yml which I assume is not used(from the flask web service directory "Pirmas"):
web:
build: .
command: python app.py
ports:
- "80:5000"
volumes:
- .:/code
What I tried:
I tried removing the volumes. Tried different paths in docker-compose.yml like python ./Pirmas/app.py
I would be grateful for any help or ideas.
Thank you.
EDIT
I'm having a similar issue when trying to launch another project, but this time a Spring Boot application.
The project structure:/
- docker-compose.yml
- Dockerfile
- pom.xml
- src/
- ... other spring boot web service folders and files
- rest-bookstore/
-Dockerfile
-rest
-src
-target
-gs-rest-service-0.1.0.jar
The old Dockerfile of the first spring boot service is the same the new one is:
FROM maven:3.6.0-jdk-8-alpine
COPY rest /rest
WORKDIR /rest
RUN mvn clean package
CMD java -jar target/gs-rest-service-0.1.0.jar --server.port=5000
And the docker-compose.yml
version: '3'
services:
springboot-docker-compose-app-container:
build: .
ports:
- "80:5000"
depends_on:
- friendservice
volumes:
- .:/code
networks:
- mynet
friendservice:
build: ./rest-bookstore
volumes:
- ./rest-bookstore:/rest
ports:
- 5000:5001
networks:
- mynet
networks:
mynet:
I get error:
Unable to access jarfile target/gs-rest-service-0.1.0.jar
And I don't know why since in the new dockerfile it copies the whole rest directory