If I do this:
const image = client.directory().withNewFile(
"Dockerfile",
`
FROM alpine
`
);
const builder = client
.container()
.build(image)
.withWorkdir("/")
.withEntrypoint(["sh", "-c"])
.withExec(["echo htrshtrhrthrts > file.txt"])
.withExec(["cat file.txt"]);
const anotherImage = client
.container()
.from("alpine")
.withWorkdir("/")
.withFile("/copied-file.txt", builder.file("/file.txt"))
.withEntrypoint(["sh", "-c"])
.withExec(["cat copied-file.txt"]);
It fails. But if I do this:
const builder = client
.container()
.from("alpine") // from instead of build
.withWorkdir("/")
.withEntrypoint(["sh", "-c"])
.withExec(["echo htrshtrhrthrts > file.txt"])
.withExec(["cat file.txt"]);
const anotherImage = client
.container()
.from("alpine")
.withWorkdir("/")
.withFile("/copied-file.txt", builder.file("/file.txt"))
.withEntrypoint(["sh", "-c"])
.withExec(["cat copied-file.txt"]);
It works. Why is that? 🐛 ?