docker commit
As explained in the previous sections, there are primarily two ways to create an image. While Dockerfile and docker build
together allows us to create an image using a completely scripted approach, docker commit
allows us to convert an existing container to an image. It also gives you an option to update the existing container's Dockerfile using the command-line arguments.
For example, the following set of commands create a container from scratch and then convert the container into a redistributable image. In this example, we will install a Redis on our container and convert it into an image to reuse in the following chapters:
- Create a container using the following command. This creates an instance of Windows Server Core and opens an interactive shell (since we used
-it
flags) with PowerShell (you can also useCMD
in the place of PowerShell):
docker run -it microsoft/windowsservercore powershell
- Now we can start customizing our container. Use the following command to download...