我正在尝试创建Jahia CMS(数字体验管理器)的Docker安装。
我需要 :
- 一个MySQL容器
- Jahia容器(嵌入式Tomcat)
诀窍是在 Jahia 容器构建期间(使用Expect安装产品),我需要访问 MySQL 容器(需要连接检查)。
MySQL Docker 文件:
FROM mysql:5.6
Jahia 码头文件:
FROM centos:centos6
# Install dependencies
RUN yum -y update && yum -y install ...
# Download Digital Experience Manager 7.1.1
RUN wget -q https://www.jahia.com/downloads/jahia/digitalexperiencemanager7.1.1/DigitalExperienceManager-EnterpriseDistribution-7.1.1.0-r53717.3663.jar -O /tmp/DigitalExperienceManager.jar
# Download MySQL connector (only needed for standalone db installation)
RUN wget -q http://central.maven.org/maven2/mysql/mysql-connector-java/5.1.44/mysql-connector-java-5.1.44.jar -O /usr/lib/mysql-connector-java-5.1.44.jar
# Launch installation using Expect to automate user input
COPY jahia_conf.exp /tmp/configuration.exp
RUN expect /tmp/configuration.exp
# Start Jahia
/opt/DigitalExperienceManager-EnterpriseDistribution-7.1.1.0/tomcat/bin/catalina.sh jpda run
期望脚本( jahia_conf.exp )
#!/bin/sh
#!/usr/bin/expect
spawn java -jar /tmp/DigitalExperienceManager.jar -console
# Installation directory
expect "Select target path"
send "/opt/DigitalExperienceManager-EnterpriseDistribution-7.1.1.0\r"
# MySQL connector JAR file
expect "Specify the path to the downloaded driver JAR file"
send "/usr/lib/mysql-connector-java-5.1.44.jar\r"
# Database configuration
expect "Database URL (*)"
send "jdbc:mysql://mysql:3306/jahia?useUnicode=true&characterEncoding=UTF-8&useServerPrepStmts=false\r"
当然,我在图像构建期间遇到错误,因为它会在数据库 URL 输入后立即检查连接:
建立与数据库 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException 的连接时出错:通信链接失败
最后一个成功发送到服务器的数据包是 0 毫秒前。驱动程序没有收到来自服务器的任何数据包..
事实上,我只是在构建Jahia 映像,因此mysql
容器还无法访问(即使正在运行)。
如何处理这种情况(在构建过程中需要访问另一个容器时)?