Not able to save docker image as tar on EC2

0

I am using t2.medium with 24 GB space. I installed docker and then built my image which is working fine. It took around 10 GB so overall consumed is 12gb now 51% space is available on instance. When I try to save it as .tar it says no space left. I then tried to save it directly to s3 location, it worked fine. I removed the image from docker and pruned docker system, then loaded image from s3 and ran the image, it worked flawlessly.

But now to test portability I created a new EC2 instance with 16GB, and tried loading. 15gb is left on new instance it says can't load image : no space left on device.

How.. where is the space being used on EC2 can someone help me with this. Thanks

asked 2 days ago70 views
2 Answers
1

Hello,

Your EC2 instance lacks the necessary space to load the Docker image because Docker requires extra space temporarily during the loading process.

Verify Actual Disk Usage: Run df -h to confirm free space on your EC2 instance and identify any hidden space hogs.

Increase Disk Space: Use a larger volume (e.g., 32GB) on your EC2 instance.

Load from S3: Upload the image to S3 and load it directly on the new instance

aws s3 cp s3://mybucket/myimage.tar myimage.tar
docker load -i myimage.tar

Inspect Image Layers: Use docker image inspect <image_name> to see individual layer sizes and pinpoint bulky layers.

Prune Docker: Regularly clean up Docker to free space.

docker system prune -a
answered 2 days ago
0

Hi Nithin Nair,

please go through the below steps it will helps resolve your issue.

  • Check Docker Disk Usage: Docker can accumulate a lot of data, including images, containers, volumes, and other artifacts. Use the docker system df command to check the disk usage by Docker and see if there are any large volumes or images taking up space.

  • Check EC2 Disk Usage: Besides Docker, check the overall disk usage on your EC2 instance. Use the df -h command to see the disk space usage on the instance. Make sure that Docker is not consuming all available space, leaving insufficient space for other operations.

  • Temporary Files: Docker may create temporary files during image building or other operations. These files can take up space temporarily. Check for any temporary files or directories that can be safely deleted.

  • Clean up Unused Images and Containers: Run docker image prune and docker container prune commands to remove unused images and containers respectively. This can free up a significant amount of disk space.

  • Check Docker Configuration: Ensure Docker is configured to use the appropriate storage driver and that it's not configured to use an excessive amount of disk space for logs or other purposes.

  • Check for Large Files: Use commands like du -h to identify large files or directories that are consuming space. You might find unexpected files or logs that can be cleaned up.

  • Consider Instance Size: If your Docker images are consistently large, you may need to consider using instances with larger disk space or using Amazon EBS volumes to store Docker data.

  • Check for Errors: Look for any error messages or warnings when trying to save or load Docker images. They might provide clues about what's causing the issue.

answered 2 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions