简体   繁体   中英

Connect tomcat container to mysql container

I am trying to connect a container with tomcat to a container with mysql in order to deploy an app. I have reproduced the same into a vagrant machine (tomcat 6, mysql 5.6) but now I want to do it using docker containers. I used this answer here with some extra additions. For the mysql container I run:

sudo docker run --name mysql -e MYSQL_USER=root -e MYSQL_ROOT_PASSWORD=admin -e MYSQL_DATABASE=my_database_name -d mysql:5.6

For the Tomcat container

docker run -d -p 8080:8080 --name tomcat --link mysql:mysql -v $PWD/webapp:/usr/local/tomcat/webapps tomcat:6

Also I have the folder webapp/with_my_app.war. So far so good.

This specific app needs some config in the WEB-INF/context.xml file, so I run

docker exec -it tomcat bash

Then I updated and installed vim and finally edit the context.xml file and restarted tomcat.

But I cannot access my app at localhost:8080/with_my_app

What am I missing?

运行tomcat容器时包括--cap-add SYS_PTRACE

docker run -d -p 8080:8080 --cap-add SYS_PTRACE ......

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM