A Dockerfile is the proper way to build an image, and I’d always pick it. But docker commit exists, and it is handy for a one-off snapshot of a container you poked around in.
docker commit <container> myname/testimage:version3
That creates a new image from the container’s filesystem changes. The docs give a second form that edits the image configuration at the same time:
docker commit --change "ENV DEBUG=true" <container> myname/testimage:version3
docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" <container> myname/testimage:version4
--change (short -c) applies Dockerfile instructions to the new image. The docs list CMD, ENTRYPOINT, ENV, EXPOSE, LABEL, ONBUILD, USER, VOLUME and WORKDIR. You can add -m for a commit message and -a for an author.
Two things to know. First, by default the container and its processes are paused while the image is committed. If that is a problem, --no-pause turns it off. Second, the docs state that commits do not include any data in mounted volumes. If your container keeps its data in a volume, the image will not contain it.
Because nothing records how the image was made, I would treat a committed image as a snapshot for debugging or a quick copy, and not as something to share. Anyone who wants to rebuild it later has only the layers, no recipe.
Further reading: docker container commit