我是刚来码头的。我正在尝试创建一个运行以下命令:
docker build .下面是我的Dockerfile:
# gets the docker image of ruby 2.5 and lets us build on top of that
FROM ruby:2.3.1-slim
RUN uname --kernel-name --kernel-release --machine
RUN cat /etc/os-release
# W: There is no public key available for the following key IDs: AA8E81B4331F7F50
# RUN apt-get install -y debian-archive-keyring
# RUN apt-key update
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA8E81B4331F7F50
# install rails dependencies
RUN apt-get update && apt-get upgrade
RUN apt-get install -y curl
RUN apt-get install -y build-essential libpq-dev git-core zlib1g-dev libreadline-dev libyaml-dev libxml2-dev
RUN apt-get install -y libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev curl
RUN echo "Curl version:"
RUN curl --version
RUN curl -o- -L https://deb.nodesource.com/setup_12.x | bash -
# Install Yarn from script
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -
RUN echo "Yarn install version"
RUN yarn --version
# RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
# create a folder /myapp in the docker container and go into that folder
RUN mkdir /avocado
WORKDIR /avocado
# Copy the Gemfile and Gemfile.lock from app root directory into the /avocado/ folder in the docker container
COPY Gemfile /avocado/Gemfile
COPY Gemfile.lock /avocado/Gemfile.lock
# Run bundle install to install gems inside the gemfile
RUN bundle install
# Copy the whole app
COPY . /avocado例如,docker脚本在行中失败:
RUN curl -o- -L https://deb.nodesource.com/setup_12.x | bash -由于某些原因,然后更改脚本并运行停靠程序构建.,但是Docker从一开始就开始运行。这对我来说很不方便,也很费时。为了达到这一点,它是失败的,我必须等待几乎4GB的存储空间被重新做,并采取了大约10百万,然后我知道我的改变工作是否。
如果它能继续从失败的地方运行,这将是很好的,例如,对于这一行继续运行。
RUN curl -o- -L https://deb.nodesource.com/setup_12.x | bash -我想知道如何做到这一点?或者你有什么更好的方法来解决这个问题?
发布于 2019-09-06 10:47:19
docker只缓存那些成功构建并从失败的下一个层开始的层,除非您显式地传递@linpy中提到的--no-cache。所以在你的情况下
# Install Yarn from script
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -
RUN echo "Yarn install version"
RUN yarn --version
.
.
.在上述情况下,如果它在curl处失败,那么它将在下一次编译时从curl开始,然后构建层的其余部分。
解决方案:
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -https://stackoverflow.com/questions/57820434
复制相似问题