How to create a new docker image from a running container on Amazon?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Creating a new Docker image from a running container on AWS uses the same Docker commands you would use anywhere else. The usual workflow is to identify the running container, commit it into a new image, tag that image, and optionally push it to a registry such as Amazon ECR.
This is useful for snapshots, debugging, or preserving a temporary container state. It is not the best long-term build strategy for reproducible deployments, but it can be practical when you need to capture a live container quickly.
Find the Running Container
Start by listing running containers on the EC2 instance or other host:
You might see output like this:
The container ID or container name is what you will use for the snapshot.
Commit the Container to a New Image
Use docker commit to create a new image from the current container filesystem:
That creates a local image named myapp:snapshot. You can confirm it with:
You can also attach a message to the commit:
This is a quick way to preserve the state after manual debugging or recovery work.
Tag the Image for Amazon ECR
If you want to store the image in AWS, tag it with your ECR repository URI:
Then authenticate and push:
Related reading
- How to create a post-init container in Kubernetes?
- How to create named and latest tag in Docker?
- How to create new docker image based on existing image?
- How to create postgis extension for postgresql in docker?
- How to create a new version of a Lambda function using CloudFormation?
- How to create an ec2 instance using boto3
- How to create a ServiceMonitor for prometheus-operator?
- How to create a tensorflow serving client for the 'wide and deep' model?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.