docker - 我可以在构建 Docker 映像时挂载卷吗?
问题描述
我正在研究 Chromium fork docker builder 图像。我更愿意为构建缓存安装一些卷。构建图像时是否可以(docker build -t mychromiumfork_builder .
)?
FROM ubuntu:16.04
# Adjust env
ENV SRC="/mychromiumfork/src" OUT="/mychromiumfork/out" GOOGLE_PLAY_AGREE_LICENSE="1" LC_CTYPE="en_US.UTF-8" CHROME_DEVEL_SANDBOX="1"
# here i'd like to add `ENV CACHE="/mychromiumfork/cache"`
# Install Chromium build dependencies.
RUN echo "deb http://archive.ubuntu.com/ubuntu trusty multiverse" >> /etc/apt/sources.list # && dpkg --add-architecture i386
RUN apt-get update && apt-get install -qy \
git \
build-essential \
clang \
curl \
lsb-core \
sudo \
--no-install-recommends
RUN mkdir -p ${SRC}
# gclient sync prerequisites
COPY .gclient /mychromiumfork
RUN touch /mychromiumfork/.gclient_entries
# Copy sources
COPY src ${SRC}
# required to skip modal dialog with user confirmation (button click required)
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
RUN chmod +x ${SRC}/build/*.sh
RUN ${SRC}/build/install-build-deps-android.sh --no-prompt \
&& apt-get clean \
&& apt-get autoremove -y
# Install Chromium's depot_tools.
ENV DEPOT_TOOLS /home/developer/depot_tools
RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS
ENV PATH $PATH:$DEPOT_TOOLS
RUN echo -e "\n# Add Chromium's depot_tools to the PATH." >> .bashrc
RUN echo "export PATH=\"\$PATH:$DEPOT_TOOLS\"" >> .bashrc
VOLUME ${OUT}
# here i'd like to add `VOLUME ${CACHE}`
RUN cd /mychromiumfork && gclient sync # here i'd like to add `--cache-dir ${CACHE}`
WORKDIR ${SRC}
#RUN gn gen --args='target_os="android" is_debug=true proprietary_codecs=true ffmpeg_branding="Chrome"' ${OUT}/Debug
#CMD ninja -C ${OUT}/Debug chrome_public_apk
像这样使用:
docker build -t mychromiumfork_builder . # i'd like to pass -v ${PWD}/cache:/mychromiumfork/cache
docker create -v ${PWD}/out:/mychromiumfork/out --name mychromiumfork mychromiumfork_builder /bin/true
docker run -it --volumes-from=mychromiumfork mychromiumfork_builder
解决方案
这暂时不可用。目前,卷只能挂载到正在运行的容器上,而不能挂载到镜像上。
检查这个未解决的问题以获取更多信息。
推荐阅读
- makefile - dirname 文件列表和 Makefile 的奇怪行为
- javascript - 脚本部分仅在一个视图中有效
- mysql - 如何处理where子句中的非ASCII字符
- ip - 如何获取 Bamboo IP 地址
- typescript - VS Code 中的 TypeScript:[ts] 无法归档名称控制台
- fullcalendar - 如何实现全日历工具提示
- c# - 建模和验证具有多个提交的表单
- mysql - 如何拆分一个大的mysqldump文件以分别获取每个结构和数据?
- powershell - 使用 powershell 在 Active Directory 对象的 ACL 中设置“写入成员属性”
- python - Pygame 图形:鼠标控制。