Dockerizing Magnolia is not considered best practice. You have been warned
However, since using Docker together with Magnolia is clearly popular and growing in popularity, even if we do not advise Dockerizing Magnolia, we need to be able to provide a solution to those who must use it. This section will go through some aspects of Dockerizing Magnolia.
First - What is Docker?
Docker containers are basically lightweight type II virtual machines. Another way to think of it: Docker containers are like apps that come bundled with all their dependencies. That's really it. You can drop a Docker container into any system running Docker, and it should just work. For example, you can run a Docker container on an EC2 instance, as long as that instance has Docker installed. In fact, you can run N Docker containers on any 1 or N EC2 instances. The key question here is: Why would I want to do something like this? Well, let's assume some business rules force you to use Docker.
Next - Why (Not) Docker?
Advantages
easy rollback of changes (docker history)
See explanation, below.
start-up speed
See explanation, below.
more CI-able?
Because Docker containers can be quickly created and destroyed, and because they will work the same way anywhere you run them, if a container works on your Dev machine, it will also work on your Prod (or any other env) machine. Since we can integrate Docker with jenkins or travis or teamcity and git, a developer could submit code to github, automatically test and trigger a build, and then add it to nexus.
self-contained
not tightly coupled to OS / tool (e.g., RHEL, AWS)
scalability
We have an image that we know is the same as all other such images and can work anywhere. Therefore we should be able to quickly and easily create N such instances.
Disadvantages
disk usage could go up
See explanation, below.
if you're not using Linux, you need VirtualBox-ish
running systemctl or systemd units inside a container seems impossible / very difficult
best practices lead to lots of framework
E.g., the suggested basic Magnolia setup (1 author, 2 publics, each with different database) would require 6 different docker containers. Those 6 docker containers would have to be strung together with Docker compose, and Docker compose does not seem to work on multiple hosts, so, you'd also need to set up a Docker swarm.
to fully utilize CI/CD, might need an enterprise-level Docker license
From a discussion with Nicolas B. in Pre-Sales room:
{quote}
[9:48 AM] Nicolas Barbé: In short, there are two issues : 1. Magnolia is stateful 2. You cannot run Two magnolia instances on the same DB. Because of that, we can't leverage advanced cloud features which are provided out-of the box by k8s or aws such as auto-scalability or B/G deployment. Our customers have to implement a lot of glue code to make it work, which kills the argument of using such platforms. With container based orchestration, the situation is even worse, because they can reallocate dynamically the containers to different hosts. This is the way failover is implemented and that the whole cluster scale. Magnolia instances must be declared as "fixed" instances, which cannot be moved to a different host. Which again kills all the advantage of having k8s (or other container based orchestrator).
Our customers ask for k8s because they have invested in this technology to leverage these otb features and to have a consistent way of managing "services".
[9:50 AM] Nicolas Barbé: To be more complete : JCR clustering is broken and k8s statefulset is not something you want to do with Magnolia
[10:13 AM] Nicolas Barbé: Sure, it's written in the Jackrabbit documentation itself https://wiki.apache.org/jackrabbit/Clustering [10:15 AM] Nicolas Barbé: In short, JCR clustering uses a log. This log is used to spin up new instances and sync them (index) relatively quickly. The log grows up quickly, to clean-up the log, you need to activate the janitor. If you do so, you can't spin up new instances since part of the history will be missing [10:16 AM] Nicolas Barbé: Plus, even with this mechanism, creating the new instance is not something obvious. [10:17 AM] Nicolas Barbé: Good new is that things are different with OAK, I don't know if other JCR implementations have the same issues
[10:18 AM] Jan Haderka:
| you can't spin up new instances since part of the history will be missing
[10:18 AM] Jan Haderka: that's just partially true.
[10:19 AM] Jan Haderka: you can still spin new instances, but from a snapshot taken from synced cluster node after last janitor run
[10:20 AM] Jan Haderka: and there's other workarounds.
[10:22 AM] Nicolas Barbé: yes true, that's what i meant with "glue code" earlier
[10:27 AM] Nicolas Barbé: k8s and similar tools come with a cost, customers expect to get an ROI out of that mainly not writing glue code anymore. Actually in k8s there is no good way to trigger the glue code (unless it has changed)
[10:28 AM] Nicolas Barbé: Or they have to deal with low-level k8s API which limit their capability to upgrade the cluster.
{quote}
Explanation
How Docker works: There are many pre-fabricated Docker images available online (and you may make / contribute your own). For any task / service you want to run (say, mysql or tomcat), there's probably already some image in place. When you want to use an image that already exists, Docker uses an algorithm called 'copy-on-write'; this means basically lazy copying: Docker will effectively create a pointer to the image you want to use, and only creates a new image when you want to actually alter that existing image; this makes starting it up pretty fast.
To take a simple example: imagine you have Thing A. You want to use Thing A to make Thing B. In Docker, you would make Thing B FROM Thing A. At this point, you would have basically two pointers to Thing A - there is no distinct Thing B. Once you want to add something to Thing B, that pointer is broken and a new image, Thing B is created. In fact, every time you add something new, or take something away from Thing B, a new image will be created. This can lead to very bloated installs. Now that you have Thing B, it is somehow different from Thing A. How different it is we can tell using docker history.
CI / CD / CD with Docker
According to Docker's documentation, the process could go something like this:
Developer pushes a commit to GitHub
GitHub uses a webhook to notify Jenkins of the update
Jenkins pulls the GitHub repository, including the Dockerfile describing the image, as well as the application and test code.
Jenkins builds a Docker image on the Jenkins slave node
Jenkins instantiates the Docker container on the slave node, and executes the appropriate tests
If the tests are successful the image is then pushed up to Nexus
in which case, to achieve full CI/CD/CD, we'd need a step 7: production machine takes what is generated from step 6 and restarts magnolia.
Example - Basic Magnolia Container
A Dockerfile:
Dockerfile
# #
# very simple magnolia using docker
# no best practices
# #
# let's build upon centos
FROM centos:latest
# update the centos system
# add latest java
# add wget
# clean up
RUN yum -y update && yum -y install java wget && yum clean all
# ^ best practice alert: that's a bad idea:
# imagine this gets run later, and we get a diff version of a library?
# imagine this gets run later, and we get a diff version of a library, and that breaks the build?
# due to heavy problems with systemd / systemctl inside containers:
# https://github.com/gdraheim/docker-systemctl-replacement
# get tomcat by hand and use that for more control
RUN mkdir -p /tomcat
# where is tomcat
ENV CATALINA_HOME /tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
# ^ critical
# change to where tomcat is
WORKDIR $CATALINA_HOME
# fetch tomcat
ADD get_tomcat.sh $CATALINA_HOME
RUN chmod +x $CATALINA_HOME/get_tomcat.sh
RUN $CATALINA_HOME/get_tomcat.sh
# could combine this and the next step by using bundle
# would have side effect of leveraging magnolia_control.{bat|sh}
# move some things around
RUN mv $CATALINA_HOME/apache-tomcat-8.5.20/* $CATALINA_HOME/
RUN rm -rf $CATALINA_HOME/apache-tomcat-8.5.20
# ^ could be done better
# fetch latest magnolia into tomcat
WORKDIR $CATALINA_HOME/webapps
ADD get_latest_magnolia.sh $CATALINA_HOME/webapps
RUN chmod +x $CATALINA_HOME/webapps/get_latest_magnolia.sh
RUN $CATALINA_HOME/webapps/get_latest_magnolia.sh
# Expose the ports
EXPOSE 8080
# actually start Tomcat once we use this container
CMD ["catalina.sh", "run"]
[ghost@pvnp magnolia-base]$ sudo docker build -t magnolia-1 .
Sending build context to Docker daemon 7.68kB
Step 1/16 : FROM centos:latest
latest: Pulling from library/centos
d9aaf4d82f24: Pull complete
Digest: sha256:eba772bac22c86d7d6e72421b4700c3f894ab6e35475a34014ff8de74c10872e
Status: Downloaded newer image for centos:latest
---> 196e0ce0c9fb
Step 2/16 : RUN yum -y update && yum -y install java wget && yum clean all
---> Running in 22afe184a202
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
* base: mirrors.mit.edu
* extras: mirror.trouble-free.net
* updates: mirror.vtti.vt.edu
No packages marked for update
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.mit.edu
* extras: mirror.trouble-free.net
* updates: mirror.vtti.vt.edu
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.144-0.b01.el7_4 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.144-0.b01.el7_4 for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjvm.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjli.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjava.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libasound.so.2(ALSA_0.9.0rc4)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libasound.so.2(ALSA_0.9)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: fontconfig(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libpng15.so.15()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjpeg.so.62()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjli.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libawt.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libasound.so.2()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libXtst.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libXrender.so.1()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libXi.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libXext.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libXcomposite.so.1()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64
---> Package wget.x86_64 0:1.14-15.el7 will be installed
--> Running transaction check
---> Package alsa-lib.x86_64 0:1.1.3-3.el7 will be installed
---> Package fontconfig.x86_64 0:2.10.95-11.el7 will be installed
--> Processing Dependency: freetype for package: fontconfig-2.10.95-11.el7.x86_64
--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.10.95-11.el7.x86_64
--> Processing Dependency: font(:lang=en) for package: fontconfig-2.10.95-11.el7.x86_64
--> Processing Dependency: libfreetype.so.6()(64bit) for package: fontconfig-2.10.95-11.el7.x86_64
---> Package giflib.x86_64 0:4.1.6-9.el7 will be installed
--> Processing Dependency: libSM.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
--> Processing Dependency: libICE.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.144-0.b01.el7_4 will be installed
--> Processing Dependency: tzdata-java >= 2015d for package: 1:java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: copy-jdk-configs >= 2.2 for package: 1:java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el7_4.x86_64
--> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el7_4.x86_64
---> Package libX11.x86_64 0:1.6.5-1.el7 will be installed
--> Processing Dependency: libX11-common >= 1.6.5-1.el7 for package: libX11-1.6.5-1.el7.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.5-1.el7.x86_64
---> Package libXcomposite.x86_64 0:0.4.4-4.1.el7 will be installed
---> Package libXext.x86_64 0:1.3.3-3.el7 will be installed
---> Package libXi.x86_64 0:1.7.9-1.el7 will be installed
---> Package libXrender.x86_64 0:0.9.10-1.el7 will be installed
---> Package libXtst.x86_64 0:1.2.3-1.el7 will be installed
---> Package libjpeg-turbo.x86_64 0:1.2.90-5.el7 will be installed
---> Package libpng.x86_64 2:1.5.13-7.el7_2 will be installed
---> Package xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 will be installed
--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Running transaction check
---> Package copy-jdk-configs.noarch 0:2.2-3.el7 will be installed
---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
---> Package freetype.x86_64 0:2.4.11-15.el7 will be installed
---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch
--> Processing Dependency: libxslt for package: javapackages-tools-3.4.1-11.el7.noarch
---> Package libICE.x86_64 0:1.0.9-9.el7 will be installed
---> Package libSM.x86_64 0:1.2.2-2.el7 will be installed
---> Package libX11-common.noarch 0:1.6.5-1.el7 will be installed
---> Package libxcb.x86_64 0:1.12-1.el7 will be installed
--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.12-1.el7.x86_64
---> Package lksctp-tools.x86_64 0:1.0.17-2.el7 will be installed
---> Package stix-fonts.noarch 0:1.1.0-5.el7 will be installed
---> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed
---> Package tzdata-java.noarch 0:2017b-1.el7 will be installed
---> Package xorg-x11-font-utils.x86_64 1:7.5-20.el7 will be installed
--> Processing Dependency: libfontenc.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-20.el7.x86_64
--> Processing Dependency: libXfont.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-20.el7.x86_64
--> Running transaction check
---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
---> Package libXfont.x86_64 0:1.5.2-1.el7 will be installed
---> Package libfontenc.x86_64 0:1.1.3-3.el7 will be installed
---> Package libxslt.x86_64 0:1.1.28-5.el7 will be installed
---> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-11.el7.noarch
--> Running transaction check
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
java-1.8.0-openjdk x86_64 1:1.8.0.144-0.b01.el7_4 updates 238 k
wget x86_64 1.14-15.el7 base 547 k
Installing for dependencies:
alsa-lib x86_64 1.1.3-3.el7 base 421 k
copy-jdk-configs noarch 2.2-3.el7 base 18 k
fontconfig x86_64 2.10.95-11.el7 base 229 k
fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
freetype x86_64 2.4.11-15.el7 base 392 k
giflib x86_64 4.1.6-9.el7 base 40 k
java-1.8.0-openjdk-headless x86_64 1:1.8.0.144-0.b01.el7_4 updates 32 M
javapackages-tools noarch 3.4.1-11.el7 base 73 k
libICE x86_64 1.0.9-9.el7 base 66 k
libSM x86_64 1.2.2-2.el7 base 39 k
libX11 x86_64 1.6.5-1.el7 base 606 k
libX11-common noarch 1.6.5-1.el7 base 164 k
libXau x86_64 1.0.8-2.1.el7 base 29 k
libXcomposite x86_64 0.4.4-4.1.el7 base 22 k
libXext x86_64 1.3.3-3.el7 base 39 k
libXfont x86_64 1.5.2-1.el7 base 152 k
libXi x86_64 1.7.9-1.el7 base 40 k
libXrender x86_64 0.9.10-1.el7 base 26 k
libXtst x86_64 1.2.3-1.el7 base 20 k
libfontenc x86_64 1.1.3-3.el7 base 31 k
libjpeg-turbo x86_64 1.2.90-5.el7 base 134 k
libpng x86_64 2:1.5.13-7.el7_2 base 213 k
libxcb x86_64 1.12-1.el7 base 211 k
libxslt x86_64 1.1.28-5.el7 base 242 k
lksctp-tools x86_64 1.0.17-2.el7 base 88 k
python-javapackages noarch 3.4.1-11.el7 base 31 k
python-lxml x86_64 3.2.1-4.el7 base 758 k
stix-fonts noarch 1.1.0-5.el7 base 1.3 M
ttmkfdir x86_64 3.0.9-42.el7 base 48 k
tzdata-java noarch 2017b-1.el7 base 183 k
xorg-x11-font-utils x86_64 1:7.5-20.el7 base 87 k
xorg-x11-fonts-Type1 noarch 7.5-9.el7 base 521 k
Transaction Summary
================================================================================
Install 2 Packages (+32 Dependent packages)
Total download size: 38 M
Installed size: 121 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/copy-jdk-configs-2.2-3.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for copy-jdk-configs-2.2-3.el7.noarch.rpm is not installed
Public key for java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total 13 MB/s | 38 MB 00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-4.1708.el7.centos.x86_64 (@CentOS)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : freetype-2.4.11-15.el7.x86_64 1/34
Installing : libfontenc-1.1.3-3.el7.x86_64 2/34
Installing : libxslt-1.1.28-5.el7.x86_64 3/34
Installing : fontpackages-filesystem-1.44-8.el7.noarch 4/34
Installing : libjpeg-turbo-1.2.90-5.el7.x86_64 5/34
Installing : libICE-1.0.9-9.el7.x86_64 6/34
Installing : libSM-1.2.2-2.el7.x86_64 7/34
Installing : stix-fonts-1.1.0-5.el7.noarch 8/34
Installing : fontconfig-2.10.95-11.el7.x86_64 9/34
Installing : python-lxml-3.2.1-4.el7.x86_64 10/34
Installing : python-javapackages-3.4.1-11.el7.noarch 11/34
Installing : javapackages-tools-3.4.1-11.el7.noarch 12/34
Installing : libXfont-1.5.2-1.el7.x86_64 13/34
Installing : 1:xorg-x11-font-utils-7.5-20.el7.x86_64 14/34
Installing : ttmkfdir-3.0.9-42.el7.x86_64 15/34
Installing : xorg-x11-fonts-Type1-7.5-9.el7.noarch 16/34
Installing : alsa-lib-1.1.3-3.el7.x86_64 17/34
Installing : libXau-1.0.8-2.1.el7.x86_64 18/34
Installing : libxcb-1.12-1.el7.x86_64 19/34
Installing : libX11-common-1.6.5-1.el7.noarch 20/34
Installing : libX11-1.6.5-1.el7.x86_64 21/34
Installing : libXext-1.3.3-3.el7.x86_64 22/34
Installing : libXi-1.7.9-1.el7.x86_64 23/34
Installing : libXtst-1.2.3-1.el7.x86_64 24/34
Installing : giflib-4.1.6-9.el7.x86_64 25/34
Installing : libXrender-0.9.10-1.el7.x86_64 26/34
Installing : libXcomposite-0.4.4-4.1.el7.x86_64 27/34
Installing : tzdata-java-2017b-1.el7.noarch 28/34
Installing : lksctp-tools-1.0.17-2.el7.x86_64 29/34
Installing : copy-jdk-configs-2.2-3.el7.noarch 30/34
Installing : 1:java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el7_4.x86_ 31/34
Installing : 2:libpng-1.5.13-7.el7_2.x86_64 32/34
Installing : 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64 33/34
Installing : wget-1.14-15.el7.x86_64 34/34
install-info: No such file or directory for /usr/share/info/wget.info.gz
Verifying : libXext-1.3.3-3.el7.x86_64 1/34
Verifying : libX11-1.6.5-1.el7.x86_64 2/34
Verifying : libXi-1.7.9-1.el7.x86_64 3/34
Verifying : python-javapackages-3.4.1-11.el7.noarch 4/34
Verifying : libICE-1.0.9-9.el7.x86_64 5/34
Verifying : giflib-4.1.6-9.el7.x86_64 6/34
Verifying : libjpeg-turbo-1.2.90-5.el7.x86_64 7/34
Verifying : libXrender-0.9.10-1.el7.x86_64 8/34
Verifying : libXfont-1.5.2-1.el7.x86_64 9/34
Verifying : python-lxml-3.2.1-4.el7.x86_64 10/34
Verifying : 2:libpng-1.5.13-7.el7_2.x86_64 11/34
Verifying : freetype-2.4.11-15.el7.x86_64 12/34
Verifying : fontpackages-filesystem-1.44-8.el7.noarch 13/34
Verifying : ttmkfdir-3.0.9-42.el7.x86_64 14/34
Verifying : 1:java-1.8.0-openjdk-1.8.0.144-0.b01.el7_4.x86_64 15/34
Verifying : stix-fonts-1.1.0-5.el7.noarch 16/34
Verifying : copy-jdk-configs-2.2-3.el7.noarch 17/34
Verifying : libXcomposite-0.4.4-4.1.el7.x86_64 18/34
Verifying : libXtst-1.2.3-1.el7.x86_64 19/34
Verifying : lksctp-tools-1.0.17-2.el7.x86_64 20/34
Verifying : libxcb-1.12-1.el7.x86_64 21/34
Verifying : wget-1.14-15.el7.x86_64 22/34
Verifying : xorg-x11-fonts-Type1-7.5-9.el7.noarch 23/34
Verifying : libxslt-1.1.28-5.el7.x86_64 24/34
Verifying : tzdata-java-2017b-1.el7.noarch 25/34
Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el7_4.x86_ 26/34
Verifying : javapackages-tools-3.4.1-11.el7.noarch 27/34
Verifying : libX11-common-1.6.5-1.el7.noarch 28/34
Verifying : libXau-1.0.8-2.1.el7.x86_64 29/34
Verifying : libSM-1.2.2-2.el7.x86_64 30/34
Verifying : fontconfig-2.10.95-11.el7.x86_64 31/34
Verifying : libfontenc-1.1.3-3.el7.x86_64 32/34
Verifying : alsa-lib-1.1.3-3.el7.x86_64 33/34
Verifying : 1:xorg-x11-font-utils-7.5-20.el7.x86_64 34/34
Installed:
java-1.8.0-openjdk.x86_64 1:1.8.0.144-0.b01.el7_4 wget.x86_64 0:1.14-15.el7
Dependency Installed:
alsa-lib.x86_64 0:1.1.3-3.el7
copy-jdk-configs.noarch 0:2.2-3.el7
fontconfig.x86_64 0:2.10.95-11.el7
fontpackages-filesystem.noarch 0:1.44-8.el7
freetype.x86_64 0:2.4.11-15.el7
giflib.x86_64 0:4.1.6-9.el7
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.144-0.b01.el7_4
javapackages-tools.noarch 0:3.4.1-11.el7
libICE.x86_64 0:1.0.9-9.el7
libSM.x86_64 0:1.2.2-2.el7
libX11.x86_64 0:1.6.5-1.el7
libX11-common.noarch 0:1.6.5-1.el7
libXau.x86_64 0:1.0.8-2.1.el7
libXcomposite.x86_64 0:0.4.4-4.1.el7
libXext.x86_64 0:1.3.3-3.el7
libXfont.x86_64 0:1.5.2-1.el7
libXi.x86_64 0:1.7.9-1.el7
libXrender.x86_64 0:0.9.10-1.el7
libXtst.x86_64 0:1.2.3-1.el7
libfontenc.x86_64 0:1.1.3-3.el7
libjpeg-turbo.x86_64 0:1.2.90-5.el7
libpng.x86_64 2:1.5.13-7.el7_2
libxcb.x86_64 0:1.12-1.el7
libxslt.x86_64 0:1.1.28-5.el7
lksctp-tools.x86_64 0:1.0.17-2.el7
python-javapackages.noarch 0:3.4.1-11.el7
python-lxml.x86_64 0:3.2.1-4.el7
stix-fonts.noarch 0:1.1.0-5.el7
ttmkfdir.x86_64 0:3.0.9-42.el7
tzdata-java.noarch 0:2017b-1.el7
xorg-x11-font-utils.x86_64 1:7.5-20.el7
xorg-x11-fonts-Type1.noarch 0:7.5-9.el7
Complete!
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
---> a8d71bfb19cf
Removing intermediate container 22afe184a202
Step 3/16 : RUN mkdir -p /tomcat
---> Running in 9a528c0c06eb
---> 86f576d8387a
Removing intermediate container 9a528c0c06eb
Step 4/16 : ENV CATALINA_HOME /tomcat
---> Running in 6ae602d81449
---> 238dce716da1
Removing intermediate container 6ae602d81449
Step 5/16 : WORKDIR $CATALINA_HOME
---> a4f30cbfb87f
Removing intermediate container 7ecfd9a69e09
Step 6/16 : ADD get_tomcat.sh $CATALINA_HOME
---> 16bf927a7186
Step 7/16 : RUN chmod +x $CATALINA_HOME/get_tomcat.sh
---> Running in 7ab22cbc0408
---> 8889ce23b8b8
Removing intermediate container 7ab22cbc0408
Step 8/16 : RUN $CATALINA_HOME/get_tomcat.sh
---> Running in c9c6c57b9b48
---> 8b5270cb598f
Removing intermediate container c9c6c57b9b48
Step 9/16 : RUN mv $CATALINA_HOME/apache-tomcat-8.5.20/* $CATALINA_HOME/
---> Running in 5aa37fa1b504
---> 71238010620c
Removing intermediate container 5aa37fa1b504
Step 10/16 : RUN rm -rf $CATALINA_HOME/apache-tomcat-8.5.20
---> Running in d2edca974b2a
---> 05fa6126fbc2
Removing intermediate container d2edca974b2a
Step 11/16 : WORKDIR $CATALINA_HOME/webapps
---> 704052b7cc33
Removing intermediate container 7197e5e2b569
Step 12/16 : ADD get_latest_magnolia.sh $CATALINA_HOME/webapps
---> 8039b8abab97
Step 13/16 : RUN chmod +x $CATALINA_HOME/webapps/get_latest_magnolia.sh
---> Running in 01dbf588a5f7
---> c4507fd70520
Removing intermediate container 01dbf588a5f7
Step 14/16 : RUN $CATALINA_HOME/webapps/get_latest_magnolia.sh
---> Running in ca53fcfb662b
---> 50d6a91452f6
Removing intermediate container ca53fcfb662b
Step 15/16 : CMD $CATALINA_HOME/bin/catalina.sh run
---> Running in 9505f039346f
---> 35f92957b52d
Removing intermediate container 9505f039346f
Step 16/16 : EXPOSE 8080
---> Running in f73dc5888eae
---> a848ee1c2d8c
Removing intermediate container f73dc5888eae
Successfully built a848ee1c2d8c
Successfully tagged bda-1:latest
[ghost@pvnp magnolia-base]$
Now, we can go back and see everything that just happened:
[bandersen@li1397-60 docker]$ sudo docker history magnolia-1
IMAGE CREATED CREATED BY SIZE COMMENT
bdd17317d6ff 3 minutes ago /bin/sh -c #(nop) CMD ["catalina.sh" "run"] 0 B
e1e6b0e76442 3 minutes ago /bin/sh -c #(nop) EXPOSE 8080/tcp 0 B
183406bb49e2 3 minutes ago /bin/sh -c $CATALINA_HOME/webapps/get_late... 170 MB
b3d6f0e074f6 3 minutes ago /bin/sh -c chmod +x $CATALINA_HOME/webapps... 1.17 kB
b9e91f2ba419 3 minutes ago /bin/sh -c #(nop) ADD file:5d32b9a35e98094... 1.17 kB
5e4e1cda55b8 7 minutes ago /bin/sh -c #(nop) WORKDIR /tomcat/webapps 0 B
c466f5c0cc60 7 minutes ago /bin/sh -c rm -rf $CATALINA_HOME/apache-to... 0 B
b6598823e271 7 minutes ago /bin/sh -c mv $CATALINA_HOME/apache-tomcat... 13.6 MB
78e123db89b8 7 minutes ago /bin/sh -c $CATALINA_HOME/get_tomcat.sh 13.6 MB
f408c365b67a 7 minutes ago /bin/sh -c chmod +x $CATALINA_HOME/get_tom... 315 B
a905e06737ef 7 minutes ago /bin/sh -c #(nop) ADD file:fef7f742f24b284... 315 B
6fdccd490e0b 7 minutes ago /bin/sh -c #(nop) WORKDIR /tomcat 0 B
77b836791f22 7 minutes ago /bin/sh -c #(nop) ENV PATH=/tomcat/bin:/u... 0 B
602cf9f15dd4 7 minutes ago /bin/sh -c #(nop) ENV CATALINA_HOME=/tomcat 0 B
8039f2f879a6 7 minutes ago /bin/sh -c mkdir -p /tomcat 0 B
55a4fca18ee5 7 minutes ago /bin/sh -c yum -y update && yum -y install... 165 MB
e934aafc2206 11 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0 B
<missing> 11 days ago /bin/sh -c #(nop) LABEL org.label-schema.... 0 B
<missing> 11 days ago /bin/sh -c #(nop) ADD file:f755805244a649e... 199 MB
[bandersen@li1397-60 docker]$
Notice: a new image was built for every command. A new 'layer' was added. To roll things back, we can simply peel off layers.
We can see what images we now have:
[bandersen@li1397-60 docker]$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
magnolia-1 latest bdd17317d6ff 4 minutes ago 561 MB
172.30.1.1:5000/default/magnoliaauthor latest c0d8a34a0148 About an hour ago 1.28 GB
172.30.1.1:5000/default/magnoliaauthor <none> 728ea9b1a021 About an hour ago 952 MB
docker.io/openshift/origin-web-console v3.9.0 93da30625d17 18 hours ago 489 MB
docker.io/openshift/origin-docker-registry v3.9.0 332011373060 18 hours ago 458 MB
docker.io/openshift/origin-haproxy-router v3.9.0 3cc00bbb78d2 18 hours ago 1.28 GB
docker.io/openshift/origin-sti-builder v3.9.0 f0cdca432426 18 hours ago 1.25 GB
docker.io/openshift/origin-deployer v3.9.0 54163b3c1188 18 hours ago 1.25 GB
docker.io/openshift/origin v3.9.0 64dc597680f1 18 hours ago 1.25 GB
docker.io/openshift/origin-pod v3.9.0 2837a3e794fe 18 hours ago 220 MB
docker.io/centos latest e934aafc2206 11 days ago 199 MB
docker.io/openshift/wildfly-101-centos7 <none> fdd589482018 4 weeks ago 952 MB
[bandersen@li1397-60 docker]$
Notice the difference in size between the base CentOS image, and the one we have now created.
Now I could also rebuild it under a different name, or add something. This is where some of the speed comes in. If I just run it again, Docker is smart enough to realize I did not add anything, and so you'd get output like this:
[bandersen@li1397-60 docker]$ date ; sudo docker build -t magnolia-3 . ; date
Wed Apr 18 13:11:38 UTC 2018
Sending build context to Docker daemon 6.656 kB
Step 1/17 : FROM centos:latest
---> e934aafc2206
Step 2/17 : RUN yum -y update && yum -y install java wget && yum clean all
---> Using cache
---> 55a4fca18ee5
Step 3/17 : RUN mkdir -p /tomcat
---> Using cache
---> 8039f2f879a6
Step 4/17 : ENV CATALINA_HOME /tomcat
---> Using cache
---> 602cf9f15dd4
Step 5/17 : ENV PATH $CATALINA_HOME/bin:$PATH
---> Using cache
---> 77b836791f22
Step 6/17 : WORKDIR $CATALINA_HOME
---> Using cache
---> 6fdccd490e0b
Step 7/17 : ADD get_tomcat.sh $CATALINA_HOME
---> Using cache
---> a905e06737ef
Step 8/17 : RUN chmod +x $CATALINA_HOME/get_tomcat.sh
---> Using cache
---> f408c365b67a
Step 9/17 : RUN $CATALINA_HOME/get_tomcat.sh
---> Using cache
---> 78e123db89b8
Step 10/17 : RUN mv $CATALINA_HOME/apache-tomcat-8.5.30/* $CATALINA_HOME/
---> Using cache
---> b6598823e271
Step 11/17 : RUN rm -rf $CATALINA_HOME/apache-tomcat-8.5.30
---> Using cache
---> c466f5c0cc60
Step 12/17 : WORKDIR $CATALINA_HOME/webapps
---> Using cache
---> 5e4e1cda55b8
Step 13/17 : ADD get_latest_magnolia.sh $CATALINA_HOME/webapps
---> Using cache
---> b9e91f2ba419
Step 14/17 : RUN chmod +x $CATALINA_HOME/webapps/get_latest_magnolia.sh
---> Using cache
---> b3d6f0e074f6
Step 15/17 : RUN $CATALINA_HOME/webapps/get_latest_magnolia.sh
---> Using cache
---> 183406bb49e2
Step 16/17 : EXPOSE 8080
---> Using cache
---> e1e6b0e76442
Step 17/17 : CMD catalina.sh run
---> Using cache
---> bdd17317d6ff
Successfully built bdd17317d6ff
Wed Apr 18 13:11:38 UTC 2018
[bandersen@li1397-60 docker]$
See how it is "using cache" for all those steps? This took no time at all to run (literally less than one second).