0

I am new here and also new to the docker and tomcat. I am trying to deploy a maven project with docker. I have managed to create an image for tomcat in docker and created a container from that image. https://0.0.0.0:49153// or https://172.17.42.1:49153/ gives me the apache tomcat opening page; but whenever i try to enter to the web manager; i can not login with my own username and password for my local tomcat.

I guess i need to add the tomcat-users.xml configurations to my docker image but i don't know how to set a user for that. Here is my dockerfile

FROM tomcat:7-jre7 MAINTAINER "rozerinaktas <rozerinaktas@gmail.com>" // there should be an add command here i think CMD sudo service tomcat7 start && tail -f /var/log/tomcat7/catalina.out

Any help would be very appreciated.

user3104760
  • 143
  • 6
  • This is (borderline) off topic, it seems more to do with application server configuration than with programming; on the other hand it is used to deploy a self build application that uses Maven. Still, I think it has a better place at [ServerFault](http://serverfault.com) – Maarten Bodewes Sep 06 '15 at 09:20
  • how can i set the configurations? – user3104760 Sep 06 '15 at 09:34
  • if you need a user, create it with the USER directive in your Dockerfile, see the doc https://docs.docker.com/reference/builder/#user, and also http://stackoverflow.com/questions/27701930/add-user-to-docker-container – user2915097 Sep 06 '15 at 10:14
  • what im trying to achieve is to open web manager for tomcat from docker. my local tomcat server works a specific username and password but when i try to login with the same parameters, i can't. – user3104760 Sep 06 '15 at 12:17

1 Answers1

0

You need to see how can you set a user name and password for the tomcat server. In case there is a config file, you need to mount it using the -v option into the docker container or you can copy it into the container by specifying the relevant COPY command in the Dockerfile . Read up regarding this on the official page of tomcat server on the docker hub. I am sure they must have mentioned something related to setting default username and password.

I had a similar problem for MySQL. It was mentioned clearly that we can provide the default password for the user "root" for MySQL as an environment variable passed during the docker-run command or in the Dockerfile itself.

Sachin Malhotra
  • 1,211
  • 2
  • 11
  • 24
  • Where will i copy my tomcat-users.xml file in dockerfile? What is the path for that? Can you give a more detailed explanation? – user3104760 Sep 07 '15 at 06:58
  • i edited my dockerfile and everytime i try to run a new container it says ; /bin/sh: 1: sudo: not found This is my new dockerfile FROM tomcat:7-jre7 MAINTAINER "rozerinaktas " RUN adduser newuser RUN passwd newuser CMD sudo service tomcat7 start && tail -f /var/log/tomcat7/catalina.out – user3104760 Sep 07 '15 at 08:25
  • Can you also tell the command you are running for spinning up the container ? And as for the sudo part, it is possible that the base image for the tomcat:7-jre7 does not understand sudo. It might have some parts of the linux kernel but not all of them. So don't use sudo. Run directy. – Sachin Malhotra Sep 07 '15 at 11:56
  • you were right i added the sudo package into the dockerfile and made a few more changes and it worked :) – user3104760 Sep 10 '15 at 11:14