Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# I run the WildFly image in the background
goldmann@mistress:~ $ docker run -d jboss/wildfly
4f1ccb61b34b073cdb90465c4db92103021c136ff0204cfe2ce03f5cf3e005ea
# I execute bash in the container PID namespace
# I want to simulate some changes dne to the filesystem
goldmann@mistress:~ $ docker exec -it 4f1ccb61b34b073cdb90465c4db92103021c136ff0204cfe2ce03f5cf3e005ea bash
[jboss@4f1ccb61b34b ~]$ echo "I'm modifying the image" > /opt/jboss/boom
# I'm exiting the bash, container is still running
[jboss@4f1ccb61b34b ~]$ exit
# LEt's stop it
goldmann@mistress:~ $ docker stop 4f1ccb61b34b073cdb90465c4db92103021c136ff0204cfe2ce03f5cf3e005ea
4f1ccb61b34b073cdb90465c4db92103021c136ff0204cfe2ce03f5cf3e005ea
# Container is not running, look!
goldmann@mistress:~ $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# Let's commit the container that I stopped (with modified configuration)
goldmann@mistress:~ $ docker commit 4f1ccb61b34b073cdb90465c4db92103021c136ff0204cfe2ce03f5cf3e005ea
3f8cd17201be82f1ec8e56eb985d4b6d2bfc24250a99598f39712e0d9f776b77
# A new image with ID 3f8cd17201be82f1ec8e56eb985d4b6d2bfc24250a99598f39712e0d9f776b77 was created, let's run it
# I run bash overriding the default command, just to show the modification
goldmann@mistress:~ $ docker run -it --rm 3f8cd17201be82f1ec8e56eb985d4b6d2bfc24250a99598f39712e0d9f776b77 bash
[jboss@056fde2b59a9 ~]$ cat /opt/jboss/boom
I'm modifying the image
[jboss@056fde2b59a9 ~]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment