azure-cosmos-db-emulator-docker
azure-cosmos-db-emulator-docker copied to clipboard
Linux docker emulator lacks 'curl' command
Describe the bug
The linux emulator doesn't provide the curl command (or similar like wget), so it is not possible to perform a basic healtcheck (as is usual with docker compose)
Disclaimer: IMHO this is a bug, not a feature request, because a common operation with docker compose cannot be performed (unless there is an alternative way to check when CosmosDB service is ready)
To Reproduce
- Suppose the following docker compose file (compose.yaml):
services:
CosmosDb:
image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
ports:
- 443:443
- 8081:8081
- 10250-10255:10250-10255
healthcheck:
test: ["CMD", "curl", "-f", "-k", "https://localhost:8081/_explorer/emulator.pem"]
interval: 10s
retries: 12
timeout: 3s
- Run the service and wait:
PS C:\Users\FooUser\CosmosDbTest> docker compose up --wait
[+] Running 0/1
- Container cosmosdbtest-CosmosDb-1 Waiting 60.9s
container cosmosdbtest-CosmosDb-1 is unhealthy
- The container inspection reveals the problem,
curlis missing:
PS C:\Users\FooUser\CosmosDbTest> docker inspect cosmosdbtest-CosmosDb-1
[
{
"Id": "65f4798648c3889e9e23608addf423e33d9f4a47ab2ae9512fec65658a0250e5",
"Created": "2024-07-10T14:41:28.483636479Z",
"Path": "/usr/local/bin/cosmos/start.sh",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 48405,
"ExitCode": 0,
"Error": "",
"StartedAt": "2024-07-10T14:41:39.46781182Z",
"FinishedAt": "0001-01-01T00:00:00Z",
"Health": {
"Status": "unhealthy",
"FailingStreak": 308,
"Log": [
{
"Start": "2024-07-10T15:32:28.363369721Z",
"End": "2024-07-10T15:32:28.390398997Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: unable to start container process: exec: \"curl\": executable file not found in $PATH: unknown"
},
{
"Start": "2024-07-10T15:32:38.391259729Z",
"End": "2024-07-10T15:32:38.41879366Z",
"ExitCode": -1,
"Output": "OCI runtime exec failed: exec failed: unable to start container process: exec: \"curl\": executable file not found in $PATH: unknown"
},
...
Expected behavior
If curl is provided the following is expected:
PS C:\Users\FooUser\CosmosDbTest> docker compose up --wait
[+] Running 1/1
✔ Container cosmosdbwrapper-CosmosDb-1 Healthy
Desktop
- OS: Windows 11 Pro
Docker Images Used
- Linux: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest (pull date: 07/10/2024)
Docker Environment
- Docker Desktop version: 4.32.0
- Docker version: 27.0.3, build 7d4bcd8
curl could help us to add custom health checks like Jalbiero or :
healthcheck:
test: curl --insecure --fail https://localhost:8081/_explorer/index.html
I am using the following workaround, a "wrapper" image (cosmos-emulator-wrapper) that contains the curl utility:
services:
CosmosDb:
image: cosmos-emulator-wrapper
build:
dockerfile_inline: |
FROM mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl
ports:
- 443:443
- 8081:8081
- 10250-10255:10250-10255
healthcheck:
test: ["CMD", "curl", "-f", "-k", "https://localhost:8081/_explorer/emulator.pem"]
interval: 10s
retries: 12
timeout: 3s
curl is added in latest version.
Pull image from mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest