Personal opinion, for reference only: First, you get MySQL done: 1. Pull a mysql image 2. Create a 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 security reasons, it is recommended not to store data in a container, or not in a mysqlserver container. You can use -v to share local storage or other containers specifically used to store data; 3. Use root Use user and password to log in. You can decide what IP you want;
Then, my approach to tomcat is: 1. Install tomcat in an ubuntu14.04, and then expose the ubuntu container to the ssh port for easy use (some children think it is inappropriate, you should consider and learn this yourself); 2. Configure tomcat related 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 through db instead of ip;
-p 80:80: The 80% of myapp is exposed;
After starting tomcat and everything is ok, you can access it through the host IP.
Personal opinion, for reference only:
First, you get MySQL done:
1. Pull a mysql image
2. Create a container:
docker run --name=mysqlserver -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=yourpassword mysql
MYSQL_ROOT_PASSWORD=yourpassword
: Password used to initialize mysqlserverVolume is not considered here. For security reasons, it is recommended not to store data in a container, or not in a mysqlserver container. You can use -v to share local storage or other containers specifically used to store data;
3. Use root Use user and password to log in. You can decide what IP you want;
Then, my approach to tomcat is:
1. Install tomcat in an ubuntu14.04, and then expose the ubuntu container to the ssh port for easy use (some children think it is inappropriate, you should consider and learn this yourself);
2. Configure tomcat related 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 through db instead of ip;-p 80:80
: The 80% of myapp is exposed;After starting tomcat and everything is ok, you can access it through the host IP.
You can write a Dockfile. You can also download a system and then install Tomcat, mysql and other required applications by yourself.