YouTip LogoYouTip

Docker Commit Command

# Docker commit Command [![Image 3: Docker Command Manual](#)Docker Command Manual](#) * * * The `docker commit` command is used to save the current state of a container as a new Docker image. The `docker commit` command is typically used to create an image to save the state of a container, so that the image can be reused or distributed later. ### Syntax docker commit CONTAINER [REPOSITORY[:TAG]] OPTIONS Description: * **-a :** Author of the committed image. * **-c :** Apply Dockerfile instructions to create the image. * **-m :** Commit message. * **-p :** Pause the container during commit (default is true). Save a container as a new image: docker commit my_container my_new_image Save the container named `my_container` as a new image named `my_new_image`. Specify a tag: docker commit my_container my_new_image:latest Save the container as an image with the `latest` tag. Add author information and commit message: docker commit -a "John Doe" -m "Added new features" my_container my_new_image Save the container as a new image, adding author information and a commit message. Commit an image without pausing the container: docker commit --pause=false my_container my_new_image Save the container as a new image without pausing it. ### Example Start a container: docker run -d -it --name my_container ubuntu bash Make some changes: docker exec my_container apt-get update docker exec my_container apt-get install -y nginx Commit the container as a new image: docker commit -a "Your Name" -m "Installed nginx" my_container my_new_image View the new image: docker images ### Common Use Cases * **Saving Work Progress**: During development or testing, save the current state of a container as an image so it can be restored later. * **Creating Base Images**: Create custom base images for specific applications or environment configurations. * **Distributing Configurations**: Save a specific configuration or application state as an image to distribute to other team members or use in different environments. The `docker commit` command is a powerful tool that allows users to save the current state of a container as a new Docker image. By using this command, users can create custom images for reuse or distribution later. Adding appropriate author and commit messages helps track the history and changes of the image. * * Docker Command Manual](#)
← Docker Diff CommandDocker Export Command β†’