In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Dockers deploys mysql database
1. Create a new working directory
Mkdir mysql/ / New working directory cp slsaledb-2014-4-10.sql mysql/ upload and copy the library files of the mall project to the working directory cd mysql/ / enter the working directory
2. Edit the dockerfile file
Vi Dockerfile / / Edit dockerfile file
# basic image based on
FROM guyton/centos6
# basic Information
MAINTAINER this is msyql images
# copy the library file of the mall project to the container
COPY slsaledb-2014-4-10.sql /
# install mysql in the container
RUN yum-y install mysql mysql-server
# Open the database, authorize connection users for mall library files, and import library files
RUN / etc/init.d/mysqld start & &\
Mysql-e "grant all privileges on slsaledb. To 'root'@'%' identified by' 123456;" & &\
Mysql-e "grant all privileges on. * to 'root'@'localhost' identified by' abc123';" & &\
Mysql-uroot-pabc123
< /slsaledb-2014-4-10.sql #指定端口 EXPOSE 3306 #开启守护进程 CMD ["mysqld_safe"] 3、制作镜像 docker build -t centos6:mysql . //制作mysql镜像 4、开启镜像 docker run --name=mysqlserver -d -P centos6:mysql //启动mysql镜像 二、Docker部署tomcat 1、新建工作目录 mkdir tomcat 2、上传tomcat所需文件到工作目录下 cd tomcattar xf jdk-8u144-linux-x64.tar.gz -C /root/tomcat //上传并解压jdk软件包tar xf apache-tomcat-8.5.23.tar.gz -C /root/tomcat //上传并解压tomcat软件包tar xf SLSaleSystem.tar.gz -C /root/tomcat/ //上传并解压商城项目软件包 3、编辑dockerfile文件 vi Dockerfile //编辑dockfile文件 #基础镜像 FROM centos #基本信息 MAINTAINER this is tomcat image #将jdk环境包添加到容器中 ADD jdk1.8.0_144 /usr/local/java #配置容器内java环境 ENV JAVA_HOME /usr/local/java ENV JAVA_BIN /usr/local/java/bin ENV JRE_HOME /usr/local/java/jre ENV PATH $PATH:/usr/local/java/bin:/usr/local/java/jre/bin ENV CLASSPATH /usr/local/java/jre/bin:/usr/local/java/lib:/usr/local/java/jre/lib/charsets.jar #添加tomcat软件包到容器 ADD apache-tomcat-8.5.23 /usr/local/tomcat8 #启动tomcat ENTRYPOINT ["/usr/local/tomcat8/bin/catalina.sh","run"] #指定端口 EXPOSE 8080 4、更改配置文件 vi apache-tomcat-8.5.23/conf/server.xml //修改tomcat主配置文件Vi SLSaleSystem/WEB-INF/classes/jdbc.properties / / modify the database connection file of the mall project
5. Make an image
Docker build-t tomcat:centos. / / create a tomcat image
6. Enable mirroring
Docker run-d-name tomcat1-link mysqlserver:mysqlserver-v / root/tomcat/:/data1-p 8015 tomcat:centos / / Boot Image (Container Interconnection, data Volume, Port Mapping) docker ps / / View Container status
Third, web verifies access to 192.168.80.100
Summary:
The project is mainly used to test and deploy various services in docker. This project deploys web server tomcat in the container and database server mysql in the container, then mounts the mall project through data volume technology, and finally realizes the connection between containers through container interconnection technology. Of course, in a real-world application scenario, mysql will not be deployed in dockers.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.