Apache Tomcat 8 does not start in docker container

I am experimenting with Docker and am very new to this. I was struck by a point for a long time, and I did not break through and, therefore, came up with this question here ...

Problem Statement: I am trying to create an image from a docker file containing an Apache and lynx installation. After that, I try to access tomcat on the 8080 container, which in turn is redirected to the 8082 host. But when I run the image, I never run tomcat in the container.

Docker file

FROM ubuntu:16.10
#Install Lynx
Run apt-get update
Run apt-get install -y lynx

#Install Curl
Run apt-get install -y curl

#Install tools: jdk
Run apt-get update
Run apt-get install -y openjdk-8-jdk wget

#Install apache tomcat
Run groupadd tomcat
Run useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
Run cd /tmp
Run curl -O http://apache.mirrors.ionfish.org/tomcat/tomcat-    8/v8.5.12/bin/apache-tomcat-8.5.12.tar.gz
Run mkdir /opt/tomcat
Run tar xzvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
Run cd /opt/tomcat
Run chgrp -R tomcat /opt/tomcat
Run chmod -R g+r /opt/tomcat/conf
Run chmod g+x /opt/tomcat/conf
Run chown -R tomcat /opt/tomcat/webapps /opt/tomcat/work /opt/tomcat/temp opt/tomcat/logs

Run cd /opt/tomcat/bin

Expose 8080
CMD /opt/tomcat/bin/catalina.sh run && tail -f /opt/tomcat/logs/catalina.out

When the image was built, I tried to start the container in two ways below.

  • docker run -d -p 8082: 8080 imageid tail -f/dev/null , tomcat , , localhost: 8082. , , longcontainerid

  • docker run -d -p 8082: 8080 imageid/path/to/catalina.sh start tail -f/dev/null , tomcat , longconatainrid , docker ps , , localhost: 8082.

- , ?

P.s. , . , , .

+4
1

docker run , , , run, CMD Dockerfile:

(, ), CMD, COMMAND

1/ :

docker run -d -p 8082:8080 imageid tail -f /dev/null

COMMAND tail -f /dev/null, , tomcat, .

, :

docker run -d -p 8082:8080 imageid

docker log -f containerId

, tomcat.

2/ start catalina.sh. tomcat Dokerfile, :

CMD ["catalina.sh", "run"]

tomcat ( start, script, tomcat , ).

3/, tomcat ? :

FROM tomcat:latest

Docker ( , warpapps war, ) .

+1

Source: https://habr.com/ru/post/1673085/


All Articles