Shufflepuff
Shufflepuffā€¢4w ago

Run docker container in flow and curl against it

Heya, I'm trying to spin up a docker container as part of a flow and I want to wait for it to be available. Here's what I have so far, but it doesn't seem to be reachable via cURL from here.
# shellcheck shell=bash
# Bash script that calls docker as a client to the host daemon
# See documentation: https://www.windmill.dev/docs/advanced/docker
set -ex

port="${1:-3000}"

IMAGE="zfcsoftware/cf-clearance-scraper:latest"

# ensure that the image is up-to-date
docker pull $IMAGE
docker run \
--rm \
--name cf-clearance-scraper \
-d \
-p "$port":3000 \
-e PORT="$port" \
-e browserLimit=20 \
-e timeOut=60000 \
$IMAGE


# Wait for the container to be ready
while ! curl -s http://0.0.0.0:"$port" > /dev/null; do
echo "Waiting for Cloudflare Clearance Scraper..."
sleep 1
done

docker stop cf-clearance-scraper
# shellcheck shell=bash
# Bash script that calls docker as a client to the host daemon
# See documentation: https://www.windmill.dev/docs/advanced/docker
set -ex

port="${1:-3000}"

IMAGE="zfcsoftware/cf-clearance-scraper:latest"

# ensure that the image is up-to-date
docker pull $IMAGE
docker run \
--rm \
--name cf-clearance-scraper \
-d \
-p "$port":3000 \
-e PORT="$port" \
-e browserLimit=20 \
-e timeOut=60000 \
$IMAGE


# Wait for the container to be ready
while ! curl -s http://0.0.0.0:"$port" > /dev/null; do
echo "Waiting for Cloudflare Clearance Scraper..."
sleep 1
done

docker stop cf-clearance-scraper
Instead of 0.0.0.0 I've also already tried localhost and cf-clearance-scraper. Container is definitely running and exposing the port correctly:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84facc2a4e61 zfcsoftware/cf-clearance-scraper:latest "docker-entrypoint.sā€¦" 49 seconds ago Up 49 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp cf-clearance-scraper`
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
84facc2a4e61 zfcsoftware/cf-clearance-scraper:latest "docker-entrypoint.sā€¦" 49 seconds ago Up 49 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp cf-clearance-scraper`
Any ideas are welcome šŸ™‚ Thank you in advance!
2 Replies
Tiago Serafim
Tiago Serafimā€¢3w ago
The docker pull and docker run is connecting to the docker that is running in the host. The '0.0.0.0' address is the address within the container that's running the WM worker.
Shufflepuff
ShufflepuffOPā€¢3w ago
Yeah, that's what I figured, that's why I tried reaching it by the container name, but didn't had luck. So I ended up just starting the container manually on that same host and attaching it to the same network like windmill and it works.