Fixing runtime: failed to create new OS thread (have 2 already; errno=22) in Docker

Viewed 4450

I'm using Mac OS Big Sur with an M1 chip. If I try to run the docker image webdevops/php-apache, I get the following error

% docker run -it webdevops/php-apache
WARNING: The requested image's platform (linux/amd64) does not match the detected 
         host platform (linux/arm64/v8) and no specific platform was requested
-> Executing /opt/docker/provision/entrypoint.d/05-permissions.sh
-> Executing /opt/docker/provision/entrypoint.d/20-apache.sh
runtime: failed to create new OS thread (have 2 already; errno=22)
fatal error: newosproc

runtime stack:
runtime.throw(0x6430dc, 0x9)
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/panic.go:596 +0x95
runtime.newosproc(0xc420024000, 0xc420034000)
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/os_linux.go:163 +0x18c
runtime.newm(0x650dd0, 0x0)
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:1628 +0x137
runtime.main.func1()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:126 +0x36
runtime.systemstack(0x75bb00)
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:327 +0x79
runtime.mstart()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:1132

goroutine 1 [running]:
runtime.systemstack_switch()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:281 fp=0xc420020788 sp=0xc420020780
runtime.main()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/proc.go:127 +0x6c fp=0xc4200207e0 sp=0xc420020788
runtime.goexit()
    /usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc4200207e8 sp=0xc4200207e0

I can accept that my M1 mac might not be able to run this docker image, but I'm curious what, exactly, is going on here and how I might try to fix it myself.

The error itself seems related to the version of go that's inside the container, but then there's the warning

The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

Can I rebuild this image locally for arm? If so, how?

Also, for bonus points, why was I able to pull webdevops/php-apache with a non-matching arcetecture, but when I attempt to pull the mysql image, it fails with an arm64 warning?

% docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
no matching manifest for linux/arm64/v8 in the manifest list entries
1 Answers

I solved this problem like this. I created new dockerfile in main file and added this code

FROM webdevops/php-apache:8.0

RUN wget -O "/usr/local/bin/go-replace" "https://github.com/webdevops/goreplace/releases/download/1.1.2/gr-arm64-linux" \
    && chmod +x "/usr/local/bin/go-replace" \
    && "/usr/local/bin/go-replace" --version

and updated the docker-compose.yml and then started my app.

Related