The Solutions:
Solution 1: Dockerfile Image Update
The "runtime/cgo: pthread_create failed: Operation not permitted" error you’re encountering when building your Go image with CircleCI is most likely due to a change in the base Docker image you’re using. Specifically, the error is caused by a regression introduced in Docker images released around mid-June that affects Go programs using cgo.
To resolve this issue, you should update the base image in your Dockerfile to a version released after mid-June. In your case, you can use golang:1.19.1
as the base image, which was released on July 12, 2023.
Here’s the updated Dockerfile:
FROM golang:1.19.1
# ... rest of your Dockerfile remains the same ...
Once you update your Dockerfile, you should be able to build and push your Go image without encountering the error.
Q&A
I was building and pushing Docker Image to ECR with CircleCi, and it was working fine until June, but since July, I started getting the following error.
I checked the Go image github and the architecture commit came in mid-June, so this is most likely the problem.