Skip to content

Instantly share code, notes, and snippets.

@nicerobot
Last active November 4, 2018 03:08
Show Gist options
  • Select an option

  • Save nicerobot/6461f4aa65877e88485c8a0b888a579c to your computer and use it in GitHub Desktop.

Select an option

Save nicerobot/6461f4aa65877e88485c8a0b888a579c to your computer and use it in GitHub Desktop.
Docker daemon hangs opening (or writing) to fifo #911 https://github.com/docker/for-mac/issues/911
app
6461f4aa65877e88485c8a0b888a579c
  • This locks-up on macos.
  • It's something due to the out fifo.
  • Reading from the in fifo seems to work ok.
  • Works great on Linux.
make run
FROM scratch
COPY app /
ENTRYPOINT ["/app"]
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"time"
)
//
func main() {
var in *bufio.Reader
if i, err := os.OpenFile("in", os.O_RDONLY, 0); err != nil {
log.Fatalln(err)
return
} else {
in = bufio.NewReader(i)
}
out, err := os.OpenFile("out", os.O_WRONLY, 0666)
if err != nil {
log.Fatalln(err)
return
}
defer out.Close()
for {
line, err := in.ReadBytes('\n')
if err == io.EOF {
return
}
if err != nil {
log.Println(err)
return
} else {
log.Println(string(line))
fmt.Fprint(out, time.Now(), string(line))
}
}
}
build: app
docker build --tag pipe .
SOURCES := $(wildcard *.go)
app: $(SOURCES)
go vet
env CGO=false GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -installsuffix cgo -v -o $@
go build -o $@
run: in out build
cat out &
docker run -d --name fifo -v $(PWD)/in:/in -v $(PWD)/out:/out pipe
cat main.go >in
in out:
mkfifo $@
clean:
rm -f in out app 6461f4aa65877e88485c8a0b888a579c
docker rm fifo || true
docker rmi pipe:latest || true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment