Open
Description
File: develop/develop-images/dockerfile_best-practices.md
Please consider clarifying whether the pipefail option set by "RUN set -o pipefail &&" carries over to subsequent RUN commands. In a bash script the pipefail setting would carry over to subsequent commands, but it's not clear to me whether it would in a Dockerfile. I would guess maybe the answer is no because no files are affected by the setting and so there's nothing in the resulting layer that preserves the setting.
By the same token, would it work just to "RUN set -o pipefail" once and have it carry over to subsequent RUN commands, or is that not possible.
Activity
thaJeztah commentedon Dec 2, 2020
Thanks for reporting; the
set -o
won't be inherited by followingRUN
steps. EachRUN
runs in a new container, and because of that, changes that are only present in memory (likeset
, but also (e.g.)export SOMEVAR=somevalue
) are not persisted. Changes that are made to the filesystem on the other hand are persisted, so would be available inRUN
steps after that.I agree that this may need to be explained better (contributions welcome); perhaps also in the Dockerfile reference; https://docs.docker.com/engine/reference/builder/#run (that file is maintained in the CLI repository though, so would need a separate pull request; https://github.com/docker/cli/blob/master/docs/reference/builder.md)
docker-robot commentedon Nov 23, 2023
There hasn't been any activity on this issue for a long time.
If the problem is still relevant, mark the issue as fresh with a
/remove-lifecycle stale
comment.If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.
Prevent issues from auto-closing with a
/lifecycle frozen
comment./lifecycle stale
docker-robot commentedon Jan 6, 2024
Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.
If you have found a problem that seems similar to this, please open a new issue.
/lifecycle locked
thaJeztah commentedon Jan 6, 2024
Looks like this closed before being improved; let me mark it as "frozen"
2 remaining items