Hello, everyone, has anyone deployed java web projects using docker?
I have some questions, what I know now: I can use DaoCloud or hourly cloud to build a host running tomcat, or I can build a host running mysql, but I don’t know how I can deploy mysql and tomcat on the same host (do I need to write the dockerfile myself? ), and set mysql password, I want to run a java website project.
Thanks in advance.
Personal view, for reference only:
First of all, you get Mysql done:
1. Pull an image of mysql
2. Create container:
docker run --name=mysqlserver -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=yourpassword mysql
MYSQL_ROOT_PASSWORD=yourpassword: password used to initialize mysqlserver
Volume is not considered here. For the sake of safety, data storage is not recommended to be placed in the container or mysqlserver container. You can use -v to share local storage or other containers specially used to store data.
3. Use root user and password to log in. What is ip you want?
Then, tomcat, what I did was:
1. Install tomcat in an ubuntu14.04, and then expose the container of ubuntu to ssh port for easy use (there are also children’s shoes that feel inappropriate, so consider and learn this yourself);
2. Configure tomcat and deploy web applications:
docker run -it -v /root/mnt_host:/root/mnt_container --name=myapp --link=mysqlserver:db -p 80:80 -p 4000:22 ubuntu:hardy /bin/bash
--link=mysqlserver:db: This allows tomcat to access mysql； via db instead of ip;
-p 80:80: exposed 80% of myapp;
After tomcat is started and everything is ok, it can be accessed through host ip.