saharsa
saharsa

Reputation: 497

How can I fix the Error of Docker-compose up exited with code 1

I am beginner in Docker. I have a simple DockerFile and Docker-compose.yml files When I use docker-compose up, then it show an error which is exited with code 1 I do not know how can I fix it. my DockerFile:

FROM openjdk:8
ENV APP_HOME /home
RUN mkdir -p $APP_HOME
ADD target/spring-docker.jar $APP_HOME/spring-docker.jar
WORKDIR $APP_HOME
EXPOSE 8080
CMD ["java","-Dspring.data.mongodb.uri=mongodb://db:27017/","-jar","/home/spring-docker.jar"]

Docker-Compose:

version: '3.1'
services:
    spring-docker:
        build: .
        restart: always
        ports: 
            - "8080:8080"
        depends_on:
           - db
    db:
        image: mongo
        volumes:
            - ./data:/data/db
        ports:
            - "27017:27017"
        restart: always

The SpringBoot is based application along with it’s mongodb database.

Upvotes: 16

Views: 109818

Answers (3)

Paul Tofunmi
Paul Tofunmi

Reputation: 530

docker may fail due to many things in the build process. To find the solution here is my advice

  1. Type docker ps -la (to list all containers that exited with error code or failed to start
  2. In the result, you should look out for the id of the container
  3. Then check the logs using: docker logs <container_id>

Upvotes: 20

mahatmanich
mahatmanich

Reputation: 11013

Reboot of windows, in my case, worked for me ... it solves a lot of issues most of the time, which still is rather sad ... :(

Upvotes: 0

Ngugi Kiarie
Ngugi Kiarie

Reputation: 1448

Might seem a little vague and all, but I find that restarting docker always helps solve this issue.

If on Windows, go to your ash tray, right click on docker icon, select restart

Regards

Upvotes: 4

Related Questions