1

I would like to ask a question regarding the docker-compose.yml and Dockerfile. Following is the situation I have met.

  1. I first use docker image build (docker image build -t test .) and docker run (docker run -p 8888:8080 -p 8889:8009 8883:8443 -v tomcat8:/usr/local/tomcat8 --name test test) to test whether my Dockerfile is ready to go, and it is working.

Dockerfile

FROM ubuntu:latest

ENV HOME /usr/local/tomcat8

RUN apt-get -y update && apt-get -y install unzip wget openjdk-8-jdk

COPY ./installERDDAP.sh $HOME/installERDDAP.sh

COPY . $HOME/

RUN chmod +x $HOME/installERDDAP.sh

WORKDIR $HOME

RUN ./installERDDAP.sh

EXPOSE 8080 8443 8009

CMD ["catalina.sh","run"]
  1. So that I script the docker-compose.yml, like below

docker-compose.yml

version: '3'

services:
   erddap:
      build:
         context: ./
         dockerfile: Dockerfile
      image: erddap_dev:2.02
      container_name: erddap
      restart: always
      ports:
         - "8888:8080"
         - "8883:8443"
         - "8889:8009"
      volumes:
         - ./tomcat8:/usr/local/tomcat8
  1. However, the error message popup and said that the file catalina.sh does not exist. When I get into the container, well, that is true. There are no files existed. But if I put RUN ls -la in the Dockerfile, I do see the files are listed, like below.
Step 12/14 : RUN ls -la
 ---> Running in fed4870bd617
total 176
drwxr-xr-x. 1 root root  4096 Sep 11 20:08 .
drwxr-xr-x. 1 root root    21 Sep 11 20:08 ..
drwxrwxr-x. 8 root root   166 Sep 11 19:31 .git
-rw-rw-r--. 1 root root    12 Sep 11 07:50 .gitignore
-rw-r--r--. 1 root root   165 Sep 11 20:08 .wget-hsts
-rw-r-----. 1 root root 19318 Jun 30 21:53 BUILDING.txt
-rw-r-----. 1 root root  5408 Jun 30 21:53 CONTRIBUTING.md
-rw-rw-r--. 1 root root   640 Sep 11 20:03 Dockerfile
-rw-r-----. 1 root root 57011 Jun 30 21:53 LICENSE
-rw-r-----. 1 root root  1726 Jun 30 21:53 NOTICE
-rw-r-----. 1 root root  3255 Jun 30 21:53 README.md
-rw-r-----. 1 root root  7136 Jun 30 21:53 RELEASE-NOTES
-rw-r-----. 1 root root 16262 Jun 30 21:53 RUNNING.txt
drwxr-x---. 2 root root  4096 Sep 11 20:08 bin
-rwxr-x---. 2 root root 25245 Jun 30 21:50 catalina.sh
drwx------. 2 root root   238 Jun 30 21:53 conf
drwxr-xr-x. 3 root root    20 Sep 11 20:08 content
drwxr-xr-x. 2 root root     6 Sep 11 20:08 data
drwxrwxr-x. 5 root root    44 Sep 11 03:46 doc
-rw-rw-r--. 1 root root   320 Sep 11 19:49 docker-compose.yml
-rwxrwxr-x. 1 root root  1030 Sep 11 19:41 installERDDAP.sh
drwxr-x---. 2 root root  4096 Sep 11 20:08 lib
drwxr-x---. 2 root root     6 Jun 30 21:49 logs
drwxr-xr-x. 2 root root    66 Sep 11 20:08 tarz
drwxr-x---. 2 root root    30 Sep 11 20:08 temp
drwxrwxr-x. 4 root root    29 Sep 11 19:41 tomcat8
drwxr-x---. 7 root root    99 Sep 11 20:08 webapps
drwxr-x---. 2 root root     6 Jun 30 21:49 work
Removing intermediate container fed4870bd617

Interestingly, these files are not also showing up in my volume directory. Could please someone tells me where am I wrong?

Thanks


1st Updates:

  • According to the suggestion below, if I commended out the volumes within docker-compose.yml or if I added WORKDIR / in front of the CMD command, none of them are working.

  • If I modified CMD commend in Dockfile from CMD ["catalina.sh","run"] to CMD ["./catalina.sh","run"] is not working, too. But if I changed to CMD ["/usr/local/tomcat8/catalina.sh","run"], the build process is completed. But the errors than become

Attaching to erddap
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program
erddap    | Cannot find /usr/local/bin/setclasspath.sh
erddap    | This file is needed to run this program

2nd Updates:

installERDDAP.sh

#!/bin/bash
mkdir tarz

wget -q https://ftp.wayne.edu/apache/tomcat/tomcat-8/v8.5.57/bin/apache-tomcat-8.5.57.tar.gz -O ./tarz/apache-tomcat-8.5.57.tar.gz
tar -xf ./tarz/apache-tomcat-8.5.57.tar.gz -C /usr/local/tomcat8 --strip 1


mkdir data

ln ./bin/catalina.sh catalina.sh
0

2 Answers 2

2

From what I can tell your bind mount may be "overriding/hiding" your container files. If your "./tomcat8" directory is not empty it will basically "override/hide" the files in your container. I would remove the volume declaration to validate if this is the case, if so then you would need to clear out your "./tomcat8" directory and when you run the container again it should populate it with the files in the container, from then forward your local directory will again "override/hide" your container files.

9
  • Side note, you may have a reason for bind mounting the whole tomcat directory including binaries, but depending on what you want to do I would think you should be mounting the "conf" directory or the "webapps" directory instead.
    – Carlos
    Commented Sep 11, 2020 at 20:54
  • I totally agreed with you, so that I have commented out the volumes in docker-compose.yml; however, I still get the error message like below.
    – Franke Hsu
    Commented Sep 11, 2020 at 21:22
  • WARNING: Image for service erddap was built because it did not already exist. To rebuild this image you must use docker-compose build or docker-compose up --build. Creating erddap ... error
    – Franke Hsu
    Commented Sep 11, 2020 at 21:22
  • ERROR: for erddap Cannot start service erddap: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"catalina.sh\": executable file not found in $PATH": unknown
    – Franke Hsu
    Commented Sep 11, 2020 at 21:22
  • Is there a specific reason you aren't using the tomcat official image? hub.docker.com/_/tomcat
    – Carlos
    Commented Sep 12, 2020 at 4:05
0

In your docker file before the line CMD ["catalina.sh","run"] put WORKDIR / And change "catalina.sh" to "./catalina.sh"

6
  • cannot get the point why I should put WORKDIR / in front of the CMD commend. But it is failed still. The error is the same.
    – Franke Hsu
    Commented Sep 11, 2020 at 21:26
  • ERROR: for 2c10417f9d23_erddap Cannot start service erddap: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"catalina.sh\": executable file not found in $PATH": unknown
    – Franke Hsu
    Commented Sep 11, 2020 at 21:26
  • ERROR: for erddap Cannot start service erddap: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"catalina.sh\": executable file not found in $PATH": unknown ERROR: Encountered errors while bringing up the project.
    – Franke Hsu
    Commented Sep 11, 2020 at 21:27
  • @FrankeHsu how about also change from "catalina.sh" to "./catalina.sh" inside CMD? Commented Sep 11, 2020 at 21:30
  • P.S. I guess I should use "/usr/local/tomcat/catalina.sh", although this is not making sense to me. Successfully built d4e32ab5e901 Successfully tagged erddap_dev:2.02 Recreating erddap ... done Attaching to erddap erddap | Cannot find /usr/local/bin/setclasspath.sh erddap | This file is needed to run this program
    – Franke Hsu
    Commented Sep 11, 2020 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.