docker-compose up giving error

Viewed 7815

I have folder structure like below

.
├── docker-compose.yml
└── web-app
    ├── create_tomcat_admin.sh
    ├── Dockerfile
    ├── pom.xml
    └── run.sh 

And my docker-compose.yml is like

version: '3'
services:
  web-app:
    build:
      context: .
      dockerfile: web-app/Dockerfile
    ports:
       - 8080:8080
    network_mode: "host"

Once i execute docker-compose build it executes perfectly and in terminal it shows like below

Step 10/15 : ADD /web-app/create_tomcat_admin_user.sh /create_tomcat_admin_user.sh
 ---> Using cache
 ---> 6ca9922b3628
 Step 11/15 : ADD /web-app/run.sh /run.sh
  ---> Using cache
  ---> c1e843f2f67a
 Step 12/15 : RUN chmod +x /*.sh
  ---> Using cache
  ---> 6b8e781b830c
 Step 13/15 : COPY /web-app/target/*.war /tomcat/webapps
  ---> Using cache
  ---> fc046d9d1d3e
 Step 14/15 : EXPOSE 8080
  ---> Using cache
  ---> 68f788c21a84
 Step 15/15 : CMD /run.sh
  ---> Using cache
  ---> d88cc5594980
 Successfully built d88cc5594980
 Successfully tagged opt_web-app:latest`

after building docker-compose, when i execute docker-compose up it is giving error

 ben@ubuntu:~/Desktop/opt$ docker-compose up
 Starting opt_web-app_1
 Attaching to opt_web-app_1
 web-app_1  | standard_init_linux.go:187: exec user process caused "no such file or directory"
 opt_web-app_1 exited with code 1
 ben@ubuntu:~/Desktop/opt$

Where i am going wrong? But error should be displayed while building docker-compose.yml right?

1 Answers

I had the same unhelpful error when I tried to run docker-compose on Windows from a project I created in Linux. If you clone a Linux project on Windows, by default Git adds Windows style line endings which mess up any Bash scripts. If this is the case run git config --global core.autocrlf false to configure Git to never change the line endings. Then delete repository and re-clone it.

Alternatively if you created the project initially on Windows, many times the IDE adds Windows style line endings. If this is the case then in Notepad++, Click edit menu > EOL Conversion > Unix.

Related