To create an image from a running container, follow these steps:
1. Identify the Running Container
Run the following command to list running containers and get the container ID or name:
docker ps
2. Commit the Container to an Image
Use the docker commit
command to create an image from the running container:
docker commit <container_id> <image_name>:<tag>
For example:
docker commit abc1234 my-custom-image:latest
3. Verify the New Image
Check if the image was created successfully:
docker images
4. (Optional) Tag and Push to a Registry
If you want to push it to Docker Hub or another registry:
docker tag my-custom-image:latest myrepo/my-custom-image:latest
docker push myrepo/my-custom-image:latest
No comments:
Post a Comment