首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使“码头构建”从上次失败的地方开始

如何使“码头构建”从上次失败的地方开始
EN

Stack Overflow用户
提问于 2019-09-06 10:37:27
回答 1查看 124关注 0票数 0

我是刚来码头的。我正在尝试创建一个运行以下命令:

代码语言:javascript
复制
docker build .

下面是我的Dockerfile:

代码语言:javascript
复制
# 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脚本在行中失败:

代码语言:javascript
复制
RUN curl -o- -L https://deb.nodesource.com/setup_12.x | bash -

由于某些原因,然后更改脚本并运行停靠程序构建.,但是Docker从一开始就开始运行。这对我来说很不方便,也很费时。为了达到这一点,它是失败的,我必须等待几乎4GB的存储空间被重新做,并采取了大约10百万,然后我知道我的改变工作是否。

如果它能继续从失败的地方运行,这将是很好的,例如,对于这一行继续运行。

代码语言:javascript
复制
RUN curl -o- -L https://deb.nodesource.com/setup_12.x | bash -

我想知道如何做到这一点?或者你有什么更好的方法来解决这个问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-06 10:47:19

docker只缓存那些成功构建并从失败的下一个层开始的层,除非您显式地传递@linpy中提到的--no-cache。所以在你的情况下

代码语言:javascript
复制
# Install Yarn from script
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -
RUN echo "Yarn install version"
RUN yarn --version
.
.
.

在上述情况下,如果它在curl处失败,那么它将在下一次编译时从curl开始,然后构建层的其余部分。

解决方案:

  • 如果下一层不依赖于此,则将这些线移到码头的末尾。
代码语言:javascript
复制
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57820434

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档