The following will show you how to create a new docker image from a running container that you have modified. The image will only exist locally, meaning you can only access and use it on the computer you create it. It will not be associated with any container registry.
We will start with the ubuntu container image as our base.
docker run -a stdin -a stdout -it ubuntu /bin/bash
Make whatever changes you want to the running container, save the changes, but do not stop the container. This likely means you'll need to run the commands after this point from another terminal:
docker commit <container name>
This creates a new image with no repository or tag (easy to find). Search for it with the following command:
docker images | head
Now tag the newly created image created from the previous command
docker tag IMAGE_ID ubuntu-my-changes
docker run -a stdin -a stdout -it ubuntu /bin/bash
❯ docker ps |grep ubuntu
90674bed3b2e ubuntu "/bin/bash" 3 minutes ago Up 3 minutes quizzical_almeida
❯ docker commit quizzical_almeida
sha256:a31f3a7f9ffe1be20ba85e5dad6e996bd1c95c1aa3dbf6f00d6e99a134479879
❯ docker images | head -3
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> a31f3a7f9ffe 7 minutes ago 397MB
❯ docker tag a31f3a7f9ffe ubuntu-my-changes
❯ docker images | head -3
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu-my-changes latest a31f3a7f9ffe 8 minutes ago 397MB
docker container stop quizzical_almeida
docker container rm quizzical_almeida
docker run -a stdin -a stdout -it ubuntu-my-changes /bin/bash
And we're done!
Adapted from: https://thenewstack.io/tutorial-create-a-docker-image-from-a-running-container/