DEV Community

Flávia Bastos
Flávia Bastos

Posted on • Originally published at flaviabastos.ca on

4 2

TIL: docker commit

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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more