#
Create a Docker Image from a Docker Container
This tutorial explains to you how we can create a Docker image from a Docker container. This tutorial has an example as well.
Supposing you want to keep the image of an existing container. This image could be the starting point for a new deployment or for creating a new test environment for instance.
What you have to do ? The response is simple: on the host computer you have to run the docker commit command.
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Options:
--author , -a
: Author--change , -c
: Apply Dockerfile instruction to the created image--message , -m
: Commit message--pause , -p
: Pause container during commit (default=true)
Here it is an example:
On this screen you can see that you can work on a container. In my case I will make a little change: I will create a new directory (named DIR1).
On the following screen you can see that there is no other running containers, but there is a new Docker image created in the local repository:
You can use this new Docker image in order to create a new Docker container :
The new container has a new ID and you can see the new DIR1 directory on it.