Commit/save Changes To A Docker Image

First modify the Container

Inside the docker, run some update, install some apps, and then exit the docker.


$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                      PORTS               NAMES
2591fe7fc48b        ubuntu              "/bin/bash"         27 minutes ago      Exited (0) 25 minutes ago                       strange_panini
4b442e0afc41        ubuntu              "/bin/bash"         31 minutes ago      Exited (1) 30 minutes ago                       eloquent_mclean
2591fe7fc48b is the one you just made some changes.

Commit Changes to Image

Create a new image by committing the changes using the following syntax:

$ docker commit [CONTAINER_ID] [new_image_name]

For example:


[ec2-user@ip-172-16-0-86 ~]$ docker commit 2591fe7fc48b ubuntu-mycli
sha256:bc823dd1981236729deb55e4251f2f66eee0bc5b4c457e9dbfc23e7ebe373e2f
[ec2-user@ip-172-16-0-86 ~]$ docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu-mycli        latest              bc823dd19812        8 seconds ago       155MB
ubuntu              latest              f643c72bc252        3 weeks ago         72.9MB
Docker is not the best practice, use Dockerfile instead as more as possible.

Comments

Popular posts from this blog