gpt4 book ai didi

docker - 我可以在构建Docker镜像时挂载卷吗?

转载 作者:行者123 更新时间:2023-12-02 20:37:59 26 4
gpt4 key购买 nike

我正在处理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

最佳答案

目前尚不可用。当前,卷只能安装在正在运行的容器上,而不能安装在镜像上。

检查此open issue以获取更多信息。

关于docker - 我可以在构建Docker镜像时挂载卷吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50562151/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com