Merge pull request #921 from tonistiigi/tmpfs-readwrite

dockerfile: make tmpfs mount readwrite by default
docker-19.03
Tibor Vass 2019-04-02 18:49:40 -07:00 committed by GitHub
commit 29d65d206e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import (
var mountTests = []integration.Test{
testMountContext,
testMountTmpfs,
}
func init() {
@ -49,3 +50,31 @@ RUN --mount=target=/context [ "$(cat /context/testfile)" == "contents0" ]
}, nil)
require.NoError(t, err)
}
func testMountTmpfs(t *testing.T, sb integration.Sandbox) {
f := getFrontend(t, sb)
dockerfile := []byte(`
FROM busybox
RUN --mount=target=/mytmp,type=tmpfs touch /mytmp/foo
RUN [ ! -f /mytmp/foo ]
`)
dir, err := tmpdir(
fstest.CreateFile("Dockerfile", dockerfile, 0600),
)
require.NoError(t, err)
defer os.RemoveAll(dir)
c, err := client.New(context.TODO(), sb.Address())
require.NoError(t, err)
defer c.Close()
_, err = f.Solve(context.TODO(), c, client.SolveOpt{
LocalDirs: map[string]string{
builder.DefaultLocalNameDockerfile: dir,
builder.DefaultLocalNameContext: dir,
},
}, nil)
require.NoError(t, err)
}

View File

@ -221,7 +221,7 @@ func parseMount(value string) (*Mount, error) {
}
if roAuto {
if m.Type == MountTypeCache {
if m.Type == MountTypeCache || m.Type == MountTypeTmpfs {
m.ReadOnly = false
} else {
m.ReadOnly = true