Skip to content

Instantly share code, notes, and snippets.

@jonwhittlestone
Created September 30, 2022 09:41
Show Gist options
  • Save jonwhittlestone/693ea178e9ef751ace352733fc145265 to your computer and use it in GitHub Desktop.
Save jonwhittlestone/693ea178e9ef751ace352733fc145265 to your computer and use it in GitHub Desktop.
useful-bash-docker-remove-named.sh
# count the docker containers where the image name is `contact-app-frontend` and the container name contains `ci_temp`
docker ps -a | awk '{ print $1,$2,$15 }' | grep contact-app-frontend | grep ci_temp | awk '{print $1 }' | awk '{print NR}' | tail -1
# remove those containers
docker ps -a | awk '{ print $1,$2,$15 }' | grep contact-app-frontend | grep ci_temp | awk '{print $1 }' | xargs -I {} docker rm -f {} || true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment