DevOps- Docker-Commit

Docker commit is a powerful technique for transforming container modifications into new, customized images. This guide demonstrates leveraging a Makefile to streamline the Docker image creation process.

Why Use Docker Commit?

  • Save custom configurations and setups.
  • Create base images for development
  • Version control Docker environments

Step-by-Step Guide Using Makefile

1. Create Initial Container

Create the base container using the Makefile:

2. Enter and Modify Container

Access the container and make modifications:

These commands perform key actions:

  • Update package lists
  • Install wget and htop
  • Download the Google homepage
  • View downloaded content

3. Commit Container Changes

Create a new image from container modifications:

4. Clean Up Old Container

Remove the original container:

5. Run New Custom Container

Launch a container from the newly created image:

6. Verify New Container

Access and confirm modifications:

Benefits of the Makefile Approach

The Makefile provides several advantages:

  • Simplified Docker workflow
  • Repeatable container creation process
  • Easy-to-understand commands
  • Reduced manual typing of complex Docker commands

Conclusion

Docker commit, combined with a well-structured Makefile, offers a powerful method for creating customized Docker images. By following these steps, you can efficiently manage and version your Docker environments.

docker commit - save container changes as a new image

Share This Tutorial:

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *