问题原文
原帖链接 · user1956609 · CC BY-SA 3.0
I'm still learning docker and AWS, and I've had a docker process running awhile with 50gb EBS storage, and now I'm out of disk space and as a result, docker no longer starts up when I reboot my instance.
When I try sudo du -h / | grep '[0-9\.]\+G' I get:
1.8G /var/lib/docker/containers/f7cf0...
17G /var/lib/docker/containers/55b7e...
2.8G /var/lib/docker/containers/987b0...
22G /var/lib/docker/containers/726b0...
44G /var/lib/docker/containers
4.3G /var/lib/docker/devicemapper/devicemapper
4.3G /var/lib/docker/devicemapper
48G /var/lib/docker
48G /var/lib
48G /var
0 /sys/bus/mdio_bus/drivers/Generic 10G PHY
50G /
And when I try sudo docker ps -a I get:
Cannot connect to the Docker daemon. Is 'docker -d' running on this host?
I don't want to touch the 726b0... process, that's the most important. Will it cause problems if I delete the .log file for 55b7e...? Is there a cleaner way to do that than to just remove the file?
社区高分解答
原帖链接 · Elad Nava · CC BY-SA 4.0
If you're using Elastic Beanstalk to run Docker, this may interest you.
I took Yonatan's command and converted it into an .ebextensions cron job that will run every X hours, and clear the Docker container logs so that they don't accumulate and clog the server. I had to modify it to use tee to avoid an ambiguous redirect bash error.
Simply create an .ebextensions directory in your repository root (next to Dockerrun.aws.json) and a docker-log-truncate.config file inside it with the following content:
commands:
add_docker_log_truncate_cronjob:
command: "crontab -l | grep -q 'eb-docker' || (crontab -l ; echo '0 * */6 * * /bin/echo 0 | tee /var/log/eb-docker/containers/*/*.log')| crontab -"
ignoreErrors: true
In this case, the command will run every 6 days and clear your Docker container logs. Note that I was not able to update my Elastic Beanstalk with this change until I terminated all affected servers, probably because Beanstalk needs some free disk space to deploy the new version.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
