On Ubuntu 14.04 (Trusty Tahr) I\'m looking for a way to stop a running container and the only information I have is the image name that was used in the Docker run comma
If you want to prefer a simple AWK approach, here Is my take:
docker rm -f $(docker ps | awk '{ if($2 == "") { print $NF}}')
$(docker ps | awk '{ if($2 == " - prints the docker container names based on input image
docker ps - list all containers
awk '{ if($2 == " - The second parsed column of docker ps gives the image name. Comparing it with your image name will execute print $NF which prints the container name.
docker rm -f removes the containers
For example, removing all running containers of ubuntu image, can be done simply as:
docker rm -f $(docker ps | awk '{ if($2 == "ubuntu:latest") { print $NF}}')
PS: Remember to include the image tag in AWK, since it's a equal comparator.