Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifying /etc/hosts or /etc/resolv.conf in build fails #39

Open
ryancox opened this issue Feb 23, 2018 · 4 comments
Open

modifying /etc/hosts or /etc/resolv.conf in build fails #39

ryancox opened this issue Feb 23, 2018 · 4 comments
Labels

Comments

@ryancox
Copy link
Contributor

ryancox commented Feb 23, 2018

While attempting to build some large-ish rather complex images, I encountered issues with modifying files in a parent image. This is a simplified repro:

# img version
img:
 version     : v0.2.3
 git hash    : d87fd73
 go version  : go1.10
 go compiler : gc
 platform    : linux/amd64

Dockerfile:

# cat parent/Dockerfile
FROM alpine:3.5
RUN touch /etc/hosts2
RUN touch /etc/hosts

Works with Docker:

# docker build -t parent:local parent
Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM alpine:3.5
 ---> 6c6084ed97e5
Step 2/3 : RUN touch /etc/hosts2
 ---> Running in fa8e9856a390
 ---> be982136ee56
Removing intermediate container fa8e9856a390
Step 3/3 : RUN touch /etc/hosts
 ---> Running in 780c5673e180
 ---> 8ccb2f085b5d
Removing intermediate container 780c5673e180
Successfully built 8ccb2f085b5d
Successfully tagged parent:local

Doesn't work with img:

# img build -t parent:local parent
Building parent:local
Setting up the rootfs... this may take a bit.
INFO[0001] resolving docker.io/library/alpine:3.5@sha256:9148d069e50eee519ec45e5683e56a1c217b61a52ed90eb77bdce674cc212f1e
RUN [/bin/sh -c touch /etc/hosts2]
--->
<--- bc0sl9ywmszi31wmcv8k0ssln 0 <nil>
RUN [/bin/sh -c touch /etc/hosts]
--->
touch: /etc/hosts: Read-only file system
<--- khsm1r5bve0h0bqmkk1l5064j 1 <nil>
solving failed: executor failed running [/bin/sh -c touch /etc/hosts]: exit code 1
@jessfraz
Copy link
Collaborator

jessfraz commented Feb 24, 2018 via email

@jessfraz
Copy link
Collaborator

so this might be /etc/hosts specific since I am mounting it as read-only https://github.com/jessfraz/img/blob/master/executor/runc/executor.go#L77

@jessfraz
Copy link
Collaborator

or rather this https://github.com/moby/buildkit/blob/master/executor/oci/spec_unix.go#L35

@jessfraz jessfraz added the bug label Mar 6, 2018
@jessfraz jessfraz changed the title Error: 'Read-only file system' when attempting to modify files in parent image during build modifying /etc/hosts or /etc/resolv.conf in build fails May 31, 2018
@kekoav
Copy link
Contributor

kekoav commented Apr 25, 2020

Does #257 cover the need here? It's probably a good idea to keep this mount read-only.... this moby/buildkit#1267 explains why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants