In a follow up to the original post Docker Scripts, Docker has made it so that you no longer need to have jq installed, you can do everything with the docker client’s inspect command and its (semi)new format feature.

I’ve updated the scripts to use the format command.

Update Scripts

docker-get-ip

docker-get-ip 1 2 # Usage: docker-get-ip (name or sha) [ -n "$1" ] && docker inspect --format "{{ .NetworkSettings.IPAddress }}" $1

docker-get-id

docker-get-id 1 2 # Usage: docker-get-id (friendly-name) [ -n "$1" ] && docker inspect --format "{{ .ID }}" $1

docker-get-image

I find this one useful for DevOps uses, when I have the friendly name, I can compare the current running container’s image with the one I expect it to have (like an update) and redeploy.

docker-get-image 1 2 # Usage: docker-get-image (friendly-name) [ -n "$1" ] && docker inspect --format "{{ .Image }}" $1

docker-get-state

docker-get-state 1 2 # Usage: docker-get-state (friendly-name) [ -n "$1" ] && docker inspect --format "{{ .State.Running }}" $1

Conclusion

These are just easy shortcuts, I’m sure you can write these in different ways or as aliases. Perhaps others will find this useful.