wait4x icon indicating copy to clipboard operation
wait4x copied to clipboard

Feature request: wait for Docker container to be running

Open W1M0R opened this issue 8 months ago • 2 comments

Thanks for this great tool! It really simplifies cross-platform scripting.

Sometimes I use the following pattern in a bash script to wait for a Docker container to be running:

until [[ "$(docker inspect -f "{{.State.Running}}" my_container_name)" == "true" ]]; do
   sleep 0.1;
 done;

It just waits until the container's Running state is true.

It would be great if wait4x could do this instead:

wait4x container my_container_name_or_id

With the new exec command, a variant of this would probably look like:

# I doubt this will work correctly in a cross-platform way due to shell expansion and requiring that `test` exists
wait4x exec 'test "$(docker inspect -f "{{.State.Running}}" my_container_name_or_id)" == "true"'
# This could work if you have a justfile that implements a check-running recipe (but it would still require the justfile to resolve any cross-platform differences)
wait4x exec 'just check-running'

The following Docker container states exist:

Enum: "created" "running" "paused" "restarting" "removing" "exited" "dead"

More information:

  1. https://docs.docker.com/reference/api/engine/version/v1.50/#tag/Container/operation/ContainerInspect
  2. https://pkg.go.dev/github.com/docker/docker/client
  3. https://github.com/containers/podman/blob/main/pkg/bindings/README.md#inspect-a-container

W1M0R avatar Jun 20 '25 09:06 W1M0R

Hey @W1M0R, thanks for your suggestion! It’s a really nice feature. By the way, we’d be happy if you want to contribute to it. If not, no worries — we can also consider adding it in the near future.

atkrad avatar Jun 25 '25 20:06 atkrad

Thanks @atkrad

W1M0R avatar Jun 25 '25 20:06 W1M0R