docker - 在 Dockerfile 中运行与手动运行时存在不同的问题。出了什么问题?

标签 docker dockerfile civicrm

我正在尝试为 CiviCRM 创建一个可靠的 Docker 镜像,因为 Docker 中心中没有任何镜像与 README 或可读的 Dockerfile 构建代码捆绑在一起。唯一有详细记录的镜像不符合标准 Docker 约定。这是项目:https://github.com/djcf/civibuild-docker

因此,我编写了这个 Dockerfile,它使用 CiviCRM buildkit 来安装标准安装。唯一的问题是它不起作用。大约一周前我已经让它工作了,但现在我所做的一切都没有成功。 (我什至尝试重新运行当前的 buildkit 提交,当时我第一次尝试在 Docker 中安装 Civi -- https://raw.githubusercontent.com/civicrm/civicrm-buildkit/666d74d1e862957986e3b91c3206e3717d7058a1/bin/civi-download-tools -- 没有运气。

Dockerfile 非常简单。

FROM colstrom/fish:ubuntu
# (this adds the Friendly Interactive Shell to Ubuntu 14.04

ENV CIVITYPE drupal-clean
ENV CMS_ROOT /buildkit/build
ENV SITE_NAME "Civi"
ENV SITE_ID "civi"
ENV TMPDIR /buildkit/tmp

RUN apt-get update; apt-get install -y curl links ssmtp
RUN curl -Ls https://civicrm.org/get-buildkit.sh | bash -s -- --full --dir /buildkit

COPY dbconf.sh /buildkit
COPY postinstall.sh /buildkit

# This is the problem part -- 
# but it makes three different errors depending on what environment its run.
RUN /buildkit/bin/civibuild create civicrm --type drupal-clean --url http://localhost:80 --admin-pass 123

RUN apt-get install -y runit
RUN /buildkit/postinstall.sh; apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

VOLUME /buildkit/build
VOLUME /var/lib/mysql

EXPOSE 80

ENTRYPOINT ["/usr/sbin/docker-entrypoint.sh"]

dbconf.sh 预安装脚本确保 MySQL 正在运行,并复制该脚本所需的一些配置。特别是,它确保 amp 可以与 MySQL 通信,该 amp 具有与 MySQL 通信的正确设置,并且该 Bower 将接受由 root 用户运行。

现在奇怪的是。

当我运行构建脚本(docker build -t civibuild )时,构建在 buildkit 构建命令的开始处失败: 第15步:运行/buildkit/dbconf.sh;/buildkit/bin/civibuild 创建 civicrm --type drupal-clean --url http://localhost:80 --admin-pass 123

---> Running in 3f9999dbdb12
* Starting MySQL database server mysqld
 ...done.
* Checking for tables which need an upgrade, are corrupt or were 
not closed cleanly.
Finished running pr-configuration, will now install CiviCRM using buildkit buildscript.
ln: failed to create symbolic link 'bower': File exists
The command '/bin/sh -c /buildkit/dbconf.sh ; /buildkit    /bin/civibuild create civicrm --type drupal-clean --url    http://localhost:80 --admin-pass 123' returned a non-zero code: 1

因此,我尝试在普通 Ubuntu 14.04 Docker 镜像中手动运行完全相同的步骤(docker run --it ubuntu:14.04/bin/bash)。这次 Civi 构建大约进行到一半,然后出现错误:

CiviCRM was isntalled successfully                 [ok]
/buildkit/app/config/drupal-clean/install.sh: line 42: 17650    
Segmentation fault      (core dumped) drush -y dis overlay

然后我尝试在 Vagrant 镜像中手动运行完全相同的步骤。这次脚本成功完成。

最佳答案

该解决方案最终追溯到无效的 docker 构建缓存。在之前的运行中,bower 安装失败,并且缓存保留了错误的符号链接(symbolic link)。

解决方案:使用 docker build --no-cache 运行。

关于docker - 在 Dockerfile 中运行与手动运行时存在不同的问题。出了什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35143301/

相关文章:

mysql - Docker-Compose:为什么我的 Rails 图像在访问 MySQL 数据库时存在权限问题?

node.js - 当尝试作为反向代理连接到 Node 应用程序时,Nginx 连接被拒绝

bash - Dockerfile 将 bash 命令分配给 var

drupal-7 - 在 Drupal View 中调整 CiViCRM 图像的大小

python - 为什么 Civicrm Create Mailing 在 Scheduled 状态下创建它?

docker - 将 nginx 容器指向 docker 中的静态文件

docker - 如何防止 Docker 容器在同一服务中的另一个容器尝试打开时打开?

caching - 下载资源时有哪些策略可以使 Dockerfile 指令缓存失效

docker - 如何列出ubuntu:16.04 docker容器中的文件?

CIVICRM,如何在联系人中选择名字或姓氏?