When I need to create a new custom Docker image, I usually start with a base image (alpine, debian, python, etc, depending on the project), running it in the interactive mode and install the tools and dependencies I will need. Once I get my container the way I want, I create a Dockerfile with all the commands I ran inside my container. It works, but I just learned that this might be unnecessary extra work.
All you need is docker commit
The process starts the same way: running a base image with interactive access and installing tools and dependencies. THEN, you run:
docker commit container_ID image_name:tag
The container ID can be found by running
docker ps on a separate tab/window. And the image name and tag is whatever name and tag you want to give it.
Now, having a
Dockerfile has its advantages, such as better way to keep version control, documentation and maintenance, but for prototyping or really small projects,
docker commit seems to be very useful.
The post TIL: docker commit was originally published at flaviabastos.ca