Docker 安装搭建 Tomcat + MySQL(2)

我选择的方式是pip安装

# 安装 pip install docker-compose # 检测 docker-compose --version # ----------------------- docker-compose version 1.23.2, build 1110ad0 编写docker-compose.yml # 这个yml文件 搭建一个mysql 一个 tomcat的容器 version: "3" services: mysql: container_name: mysql image: mysql:5.7 restart: always volumes: - ./mysql/data/:/var/lib/mysql/ - ./mysql/conf/:/etc/mysql/mysql.conf.d/ ports: - "6033:3306" environment: - MYSQL_ROOT_PASSWORD=******** tomcat: container_name: tomcat restart: always image: tomcat ports: - 8080:8080 - 8009:8009 links: - mysql:m1 #连接数据库镜像

注:

volumn里必须是路径,不能指定文件

tomcat指定外部conf的时候一直创建不成功,不知道为什么,提示

tomcat | Feb 20, 2019 2:23:29 AM org.apache.catalina.startup.Catalina load tomcat | WARNING: Unable to load server configuration from [/usr/local/tomcat/conf/server.xml] tomcat | Feb 20, 2019 2:23:29 AM org.apache.catalina.startup.Catalina start tomcat | SEVERE: Cannot start server. Server instance is not configured. tomcat exited with code 1 运行命令

注:必须在yml文件的目录下下执行

docker-compose up -d # 结果----------查看docker container------- [root@localhost docker-compose]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1a8a0165a3a8 tomcat "catalina.sh run" 7 seconds ago Up 6 seconds 0.0.0.0:8009->8009/tcp, 0.0.0.0:8080->8080/tcp tomcat ddf081e87d67 mysql:5.7 "docker-entrypoint..." 7 seconds ago Up 7 seconds 33060/tcp, 0.0.0.0:6033->3306/tcp mysql

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/7b8eeb4c73e32b70a78a611b22e036b2.html