mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 09:16:29 +00:00
Rather than bind mounting binfmt_misc filesystem, mount a copy.
For some reason, bind mounting does not always seem to work, sometimes the filesystem is empty. Mounting a fresh copy seems a better solution, and simplifies things. The container does need `CAP_SYS_ADMIN` but only on boot. Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
parent
ccfdc71a2f
commit
a6dbe8ceba
@ -12,13 +12,10 @@ ENV GOPATH=/go PATH=$PATH:/go/bin
|
|||||||
COPY main.go /go/src/binfmt/
|
COPY main.go /go/src/binfmt/
|
||||||
RUN go-compile.sh /go/src/binfmt
|
RUN go-compile.sh /go/src/binfmt
|
||||||
|
|
||||||
RUN mkdir /binfmt_misc
|
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
ENTRYPOINT []
|
ENTRYPOINT []
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY --from=qemu usr/bin/qemu-* usr/bin/
|
COPY --from=qemu usr/bin/qemu-* usr/bin/
|
||||||
COPY --from=mirror /go/bin/binfmt usr/bin/binfmt
|
COPY --from=mirror /go/bin/binfmt usr/bin/binfmt
|
||||||
COPY --from=mirror /binfmt_misc /binfmt_misc/
|
|
||||||
COPY etc/binfmt.d/00_linuxkit.conf etc/binfmt.d/00_linuxkit.conf
|
COPY etc/binfmt.d/00_linuxkit.conf etc/binfmt.d/00_linuxkit.conf
|
||||||
CMD ["/usr/bin/binfmt", "-dir", "/etc/binfmt.d/", "-mount", "/binfmt_misc"]
|
CMD ["/usr/bin/binfmt"]
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
image: binfmt
|
image: binfmt
|
||||||
|
network: true
|
||||||
arches:
|
arches:
|
||||||
- amd64
|
- amd64
|
||||||
config:
|
config:
|
||||||
binds:
|
capabilities:
|
||||||
- /proc/sys/fs/binfmt_misc:/binfmt_misc
|
- CAP_SYS_ADMIN
|
||||||
readonly: true
|
readonly: true
|
||||||
net: new
|
net: new
|
||||||
ipc: new
|
ipc: new
|
||||||
|
@ -69,6 +69,11 @@ func binfmt(line []byte) error {
|
|||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if err := syscall.Mount("binfmt_misc", mount, "binfmt_misc", 0, ""); err != nil {
|
||||||
|
log.Fatalf("Cannot mount binfmt_misc filesystem at %s: %v", mount, err)
|
||||||
|
}
|
||||||
|
defer syscall.Unmount(mount, 0)
|
||||||
|
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := ioutil.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Cannot read directory %s: %s", dir, err)
|
log.Fatalf("Cannot read directory %s: %s", dir, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user