openfaas / templates

OpenFaaS Classic templates
https://www.openfaas.com
MIT License
276 stars 228 forks source link

Issue with WSL and Docker #209

Closed jmkhael closed 3 years ago

jmkhael commented 3 years ago

Faas functions relying on openfaas/classic-watchdog:0.18.1 do not build on WSL.

$ docker build -t foo -<<EOF
FROM openfaas/classic-watchdog:0.18.1 as watchdog
FROM python:2.7-alpine
COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
EOF

output:

Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM openfaas/classic-watchdog:0.18.1 as watchdog
 ---> 94b5e0bef891
Step 2/3 : FROM python:2.7-alpine
 ---> 8579e446340f
Step 3/3 : COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
COPY failed: stat /var/lib/docker/overlay2/f7f966893b0cdb12cb513aa8e8e7bdadac31f7d03eeb46ee357ee71c7408cc33/merged/fwatchdog: no such file or directory

Expected Behaviour

Build should succeed

Current Behaviour

Builds fails with: COPY failed: stat /var/lib/docker/overlay2/xxxx/merged/fwatchdog: no such file or directory

Possible Solution

Patching the watchdog version being used in the multi-stage builds in the pulled template does the trick.

find ./ -type f -exec sed -i 's/openfaas\/classic-watchdog:0.18.1/openfaas\/classic-watchdog:0.18.2/g' {} \;

Steps to Reproduce (for bugs)

  1. faas new go-func --lang go
  2. faas build -f go-func.yml

Context

FaaS functions do not build on WSL.

Your Environment

$ docker version
Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea838
 Built:             Wed Nov 13 07:29:52 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
alexellis commented 3 years ago

Hi Johnny,

What leads you to believe that there is a difference between 0.18.1 and 0.18.2? I am seeing the same result for "docker run" (it working on MacOS)

space-mini:~ alex$ docker run -ti openfaas/classic-watchdog:0.18.1 /fwatchdog
2020/07/21 13:29:19 Version: 0.18.1 SHA: b46be5a4d9d9d55da9c4b1e50d86346e0afccf2d
2020/07/21 13:29:19 Provide a valid process via fprocess environmental variable.
panic: Provide a valid process via fprocess environmental variable.

goroutine 1 [running]:
log.Panicln(0xc000071ee8, 0x1, 0x1)
    /usr/local/go/src/log/log.go:340 +0xc0
main.main()
    /go/src/github.com/openfaas/faas/watchdog/main.go:48 +0x539
space-mini:~ alex$ docker run -ti openfaas/classic-watchdog:0.18.2 /fwatchdog
2020/07/21 13:29:22 Version: 0.18.2 SHA: 1c9e12237046fccc3e23b9ca79d0c904157e89ad
2020/07/21 13:29:22 Provide a valid process via fprocess environmental variable.
panic: Provide a valid process via fprocess environmental variable.

goroutine 1 [running]:
log.Panicln(0xc00004bee8, 0x1, 0x1)
    /usr/local/go/src/log/log.go:340 +0xc0
main.main()
    /go/src/github.com/openfaas/faas/watchdog/main.go:48 +0x539

Given that OpenFaaS doesn't mount any volumes and does nothing special with Docker other than docker build, I am not really sure that we can help you with this. Your issue seems to be repeatable a simple Dockerfile, perhaps this would be better directed to the Docker or WSL forums?

https://forums.docker.com/

Happy to re-open or move the issue to an openfaas repo if there is a reproducible issue with openfaas itself.

Alex

alexellis commented 3 years ago

/set title: Issue with WSL and Docker

alexellis commented 3 years ago

(If you're on Windows, then you may have more success with multipass from ubuntu - https://multipass.run/ or git bash (link in the workshop pre-reqs for this))

jmkhael commented 3 years ago

Hi Alex,

thanks for your answer. From my side I am unblocked by the patching the templates locally:

find ./ -type f -exec sed -i 's/openfaas\/classic-watchdog:0.18.1/openfaas\/classic-watchdog:0.18.2/g' {} \;

I think from OpenFaaS side we can update the templates to bump the classic-watchdog image to a more recent one than 0.18.1 will be enough.