Skip to content

Instantly share code, notes, and snippets.

@vissapra
Last active September 7, 2018 19:05
Show Gist options
  • Save vissapra/1cc478d71551bef604c012b38f664a6e to your computer and use it in GitHub Desktop.
Save vissapra/1cc478d71551bef604c012b38f664a6e to your computer and use it in GitHub Desktop.
Remove all containers of a image
docker ps -a | awk '{ print $1,$2 }' | grep <image> | awk '{print $1 }' | xargs -I {} docker rm {}
docker ps -a | awk '$2~/<image>/ {print $1}' | xargs -r docker rm
Docker run
docker run -ti -p 9098:9098 --env-file=env-file <image> /bin/sh
You can run the following command to get the logs for a task, running or not.
docker logs $(docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" <task_id>)
Remove all docker images for a given name
docker images | awk '{ print $1,$2,$3 }' | grep <image name> | awk '{print $3 }' | xargs -I {} docker rmi -f {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment