Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl command not available in emqx-docker 5.8.4 image for health checks #74

Open
zhongwencool opened this issue Jan 9, 2025 · 3 comments

Comments

@zhongwencool
Copy link

Hello EMQX Team,

I'm encountering an issue with the emqx/emqx Docker image version 5.8.4. I've been trying to implement a health check mechanism using the curl command to query the /status endpoint, as invoking emqx_ctl each time consumes too much CPU up to 100% peak usage, which is not ideal for health checking.

However, it appears that the curl command is not available within the 5.8.4 Docker image. When attempting to execute a health check via curl, the command is not recognized and fails.

Steps to Reproduce:

docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx:5.8.4

docker exec -u root -it emqx /bin/bash
root@f1df45009b01:/opt/emqx# curl
bash: curl: command not found

docker exec -u emqx -it emqx /bin/bash
emqx@f1df45009b01:/opt/emqx$ curl
bash: curl: command not found

Expected Behavior:

The curl command should be able to reach the EMQX status API and return a response indicating the health of the service.

Actual Behavior:

The curl command is not found or does not work within the container environment.

The CI log may contain potential errors or build failures.

https://github.com/emqx/emqx-docker/actions/runs/12638560515/job/35215085251#step:6:111

#9 3.991 debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.36.0 /usr/local/share/perl/5.36.0 /usr/lib/x86_64-linux-gnu/perl5/5.36 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl-base /usr/lib/x86_64-linux-gnu/perl/5.36 /usr/share/perl/5.36 /usr/local/lib/site_perl) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
#9 3.991 debconf: falling back to frontend: Teletype
#9 4.491 Updating certificates in /etc/ssl/certs...
#9 5.254 140 added, 0 removed; done.
#9 5.272 Setting up libgssapi-krb5-2:amd64 (1.20.1-2+deb12u2) ...
#9 5.276 Setting up libcurl4:amd64 (7.88.1-10+deb12u8) ...
#9 5.279 Setting up curl (7.88.1-10+deb12u8) ...

but not curl command available .
Also:

#9 [linux/amd64 2/4] RUN set -eu;     apt-get update;     apt-get install -y --no-install-recommends ca-certificates procps curl;     arch=$(dpkg --print-architecture);     if [ ${arch} = "amd64" ]; then sha256="48776760e500e0e38b810c9c2e4156ec5022565f700bbea121695e76463ed042"; fi;     if [ ${arch} = "arm64" ]; then sha256="dd45d06ee2f7f5ace05ec9ce53b2739b54dad2105cdfcadb6f7bb514724caf91"; fi;     . /etc/os-release;     pkg="emqx-5.8.4-${ID}${VERSION_ID}-${arch}.tar.gz";     curl -f -O -L [https://www.emqx.com/en/downloads/broker/v5.8.4/${pkg};](https://www.emqx.com/en/downloads/broker/v5.8.4/$%7Bpkg%7D;)     echo "$sha256 *$pkg" | sha256sum -c;     mkdir /opt/emqx;     tar zxf $pkg -C /opt/emqx;     find /opt/emqx -name 'swagger*.js.map' -exec rm {} +;     ln -s /opt/emqx/bin/* /usr/local/bin/;     groupadd -r -g 1000 emqx;     useradd -r -m -u 1000 -g emqx emqx;     chown -R emqx:emqx /opt/emqx;     rm -f $pkg;     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

#10 [linux/arm64 2/4] RUN set -eu;     apt-get update;     apt-get install -y --no-install-recommends ca-certificates procps curl;     arch=$(dpkg --print-architecture);     if [ ${arch} = "amd64" ]; then sha256="48776760e500e0e38b810c9c2e4156ec5022565f700bbea121695e76463ed042"; fi;     if [ ${arch} = "arm64" ]; then sha256="dd45d06ee2f7f5ace05ec9ce53b2739b54dad2105cdfcadb6f7bb514724caf91"; fi;     . /etc/os-release;     pkg="emqx-5.8.4-${ID}${VERSION_ID}-${arch}.tar.gz";     curl -f -O -L [https://www.emqx.com/en/downloads/broker/v5.8.4/${pkg};](https://www.emqx.com/en/downloads/broker/v5.8.4/$%7Bpkg%7D;)     echo "$sha256 *$pkg" | sha256sum -c;     mkdir /opt/emqx;     tar zxf $pkg -C /opt/emqx;     find /opt/emqx -name 'swagger*.js.map' -exec rm {} +;     ln -s /opt/emqx/bin/* /usr/local/bin/;     groupadd -r -g 1000 emqx;     useradd -r -m -u 1000 -g emqx emqx;     chown -R emqx:emqx /opt/emqx;     rm -f $pkg;     rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

This command run twice.

@zmstone
Copy link
Member

zmstone commented Jan 9, 2025

please pull emqx:5.8.4 for now. not emqx/emqx:5.8.4.

@id
Copy link
Collaborator

id commented Jan 9, 2025

@zhongwencool

The curl command is not found or does not work within the container environment.

the curl binary was removed to reduce image size

This command run twice.

no, it's the same command for 2 different builds for different architectures

#9 [linux/amd64 2/4]

#10 [linux/arm64 2/4]

@id
Copy link
Collaborator

id commented Jan 9, 2025

here is how you can do healtcheck without curl

services:
  emqx:
    image: emqx:latest
    healthcheck:
      test: "bash -c \"exec 3<>/dev/tcp/localhost/18083; echo -e 'GET /api/v5/status HTTP/1.1\r\nhost: localhost\r\nConnection: close\r\n\r\n' >&3; grep -qz 'emqx is running' <&3\""
      interval: 5s
      timeout: 5s
      retries: 5
    container_name: node1.emqx.io
    environment:
      - "EMQX_HOST=node1.emqx.io"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants