保存docker build命令的RUN日志

/root/build.logにログが保存される。

FROM centos:centos7

RUN \
  exec >& /root/build.log ;\
  set -eux ;\
  yum -y install epel-release ;\
  yum -y update ;\
  yum -y install PyYAML python-jinja2 python-httplib2 python-keyczar python-paramiko python-setuptools git python-pip ;\
  yum clean all ;\
  mkdir /etc/ansible/ ;\
  echo '[local]\nlocalhost\n' > /etc/ansible/hosts ;\
  mkdir /opt/ansible/ ;\
  git clone http://github.com/ansible/ansible.git /opt/ansible/ansible

WORKDIR /opt/ansible/ansible

ENV PATH /opt/ansible/ansible/bin:/bin:/usr/bin:/sbin:/usr/sbin
ENV PYTHONPATH /opt/ansible/ansible/lib
ENV ANSIBLE_LIBRARY /opt/ansible/ansible/library
docker build .

在构建错误时的处理措施

    • 長いRUNを1つづつのRUNに分割する。

 

    • 手元でbuildする場合は、–no-cacheオプションをつける。

docker build –no-cache .

&でバックグラウンドにしたい場合、\&と書く。

广告
将在 10 秒后关闭
bannerAds