Committing changes made in a Docker without using Dockerfile

  1. Comprehensive Blog on Dockers running on OCI
  2. running a Docker Container on OCI
  3. opening OCI Ports for Docker Containers
  4. Building a Docker Image by using Dockerfile
  5. Committing changes made in a Docker without using Dockerfile
  6. Pushing Docker Images to Docker Hub
  7. DevOps with Github, Docker Hub and Oracle Container Cloud Services
Goal

Sometimes you might want to do complex operations which might need you get the base image and then update changes and commit , typical example would be creating a tomcat image , deploying your war file and then committing the changes by tagging a particular version.

Spin up a container
ubuntu@dockervm:~$ docker run -it debian:latest
root@c8c24ffca1d6:/# ls
bin   dev  home  lib64	mnt  proc  run	 srv  tmp  var
boot  etc  lib	 media	opt  root  sbin  sys  usr
root@c8c24ffca1d6:/# ls > newlistfile.txt
root@c8c24ffca1d6:/# apt-get update && apt-get install -y git
Ign:1 http://cdn-fastly.deb.debian.org/debian stretch InRelease                
Get:2 http://cdn-fastly.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
...  
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@c8c24ffca1d6:/# ls
bin   dev  home  lib64	mnt		 opt   root  sbin  sys	usr
boot  etc  lib	 media	newlistfile.txt  proc  run   srv   tmp	var
root@c8c24ffca1d6:/# exit
Commit to the Repo
root@c8c24ffca1d6:/# exit
exit
ubuntu@dockervm:~$ docker ps -a
CONTAINER ID        IMAGE                        COMMAND              CREATED             STATUS                       PORTS               NAMES
c8c24ffca1d6        debian:latest                "bash"               3 minutes ago       Exited (127) 6 seconds ago                       vibrant_shirley
4ecfe884aecf        jamessmith73/debian:latest   "cat listfile.txt"   38 minutes ago      Exited (0) 38 minutes ago                        confident_yonath
c00aeaaee7ca        jamessmith73/debian:latest   "ls"                 38 minutes ago      Exited (0) 38 minutes ago                        sad_davinci
192bd7f7870f        jamessmith73/debian:latest   "bash"               39 minutes ago      Exited (0) 39 minutes ago                        blissful_goldstine
ubuntu@dockervm:~$ docker commit c8c24ffca1d6 jamessmith73/debian:2.0
sha256:75e65a41a95ef72812b3da9345bffc096a3c6f98dd6b40c52ecc6d8742a59661
..  
ubuntu@dockervm:~$ docker images
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
jamessmith73/debian   2.0                 75e65a41a95e        30 seconds ago      218MB
jamessmith73/debian   1.0                 90c1c24a6dd6        15 minutes ago      249MB
jamessmith73/debian   latest              170489bdc17e        About an hour ago   249MB
tomcat                latest              ca9e2fccef98        7 days ago          463MB
debian                latest              be2868bebaba        3 weeks ago         101MB
busybox               latest              59788edf1f3e        5 weeks ago         1.15MB
hello-world           latest              4ab4c602aa5e        8 weeks ago         1.84kB
ubuntu@dockervm:~$ 

What Next >> Pushing Docker Image to hub.docker.com