Creating an image from the container
There are a couple of ways to create images. One is by manually making changes inside a container and then committing the image. The other is to build one using a Dockerfile. In this recipe, we'll look at the former recipe and look at Dockerfiles later in the chapter.
As we start a new container, a read/write layer gets attached to it. This layer will get destroyed if we do not save it. In this recipe, we will learn how to save that layer and make a new image from the running or stopped container using the docker container commit
command. The following is the syntax for the docker container commit
command:
$ docker container commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Getting ready
Ensure that the Docker daemon is running and has access to the Ubuntu image.
How to do it...
Perform the following steps:
- Let's start a container from an
ubuntu
image using thedocker container run
command:

- Having launched the container, issue
apt-get update
from the container...