Cleaning Up Unused Docker Resources with Compose
Overview
On ECS EC2, I ran into a situation where some containers kept repeating a cycle of start → fail → start → fail,
which eventually caused the server to run out of capacity and hit no space left.
This post summarizes how I handled it at the time.
Deleting Unused Docker Resources
To delete unused Docker resources, you can run commands like the following.
1 | // コンテナ削除 |
dangling … hanging down, dangling loosely
Using Spotify’s Cleanup Images
1 | $ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /etc:/etc spotify/docker-gc |
Turning It into a docker-compose.yml
Putting this into docker-compose.yml format makes image management easier.
1 | version: '2' |
Running a One-Off Container on ECS EC2 to Clean Up
1 | ecs-cli compose \ |
ToDo
I think we need to introduce a mechanism to scan for vulnerabilities in public containers we use for the first time.
I’d like to write up more on this topic in a future post.
Cleaning Up Unused Docker Resources with Compose
https://kenzo0107.github.io/en/2018/07/11/cleanup_docker_no_required_resource/
