I tried to run cloudnativelabs/whats-my-ip
on GCP (Cloud Run), but it failed:
/home/server: line 1: syntax error: unexpected "("
Container called exit(2).
The image contains a Go program, but this looks like it tries to run it as a script. Because there's no syntax when you run a binary.
What's happening here? Why does it fail? Does it really think the entrypoint is a script? A shell script? Why?
Is this a duplicate of the exec format error
? No, at least the message is different. And as far as I can tell architectures on Docker Hub and Cloud Run match.
Steps to reproduce:
resource "google_cloud_run_v2_service" "cloud-run-test" {
name = "cloud-run-test"
location = "europe-central2"
template {
containers {
image = "cloudnativelabs/whats-my-ip"
}
}
}
$ terraform init
$ terraform apply
$ gcloud logging read 'logName:projects/PROJECT_ID/logs/run.googleapis.com%2F' --format 'text(logName, textPayload, timestamp)' --project PROJECT_ID
---
log_name: projects/PROJECT_ID/logs/run.googleapis.com%2Fvarlog%2Fsystem
text_payload: Container called exit(2).
timestamp: 2023-12-09T03:40:23.628609204Z
---
log_name: projects/PROJECT_ID/logs/run.googleapis.com%2Fstderr
text_payload: /home/server: line 1: syntax error: unexpected "("
timestamp: 2023-12-09T03:40:22.632415Z
I moved my experiments with the image to this gist.
This is not exactly the reason (depends on your definition) but this is as close as I could probably hope to get. According to the fragment of the docs John Hanley quoted:
Executables in the container image must be compiled for Linux 64-bit. Cloud Run specifically supports the Linux x86_64 ABI format.
$ docker container create cloudnativelabs/whats-my-ip
$ docker cp 97bd786fbc2dd1df6925121ae8c0febebaf1a6f8785c10a7a7237e5799791289:/home/server /tmp/server
$ docker rm 97bd786fbc2dd1df6925121ae8c0febebaf1a6f8785c10a7a7237e5799791289
$ file /tmp/server
/tmp/server: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, Go BuildID=edc3254ee8543cb3d51767295b041bc44368d286, with debug_info, not stripped
The reason is apparently because /home/server
is a 32-bit binary.