# Create a Docker Image from a Docker Container

In 
Published 2022-12-03

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.

Syntax:
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

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.