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
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:
[ghost@pvnp magnolia-base]$ docker history bda-1
IMAGE CREATED CREATED BY SIZE COMMENT
a848ee1c2d8c About a minute ago /bin/sh -c #(nop) EXPOSE 8080/tcp 0B
35f92957b52d About a minute ago /bin/sh -c #(nop) CMD ["$CATALINA_HOME/bi... 0B
50d6a91452f6 About a minute ago /bin/sh -c $CATALINA_HOME/webapps/get_late... 169MB
c4507fd70520 6 minutes ago /bin/sh -c chmod +x $CATALINA_HOME/webapps... 1.17kB
8039b8abab97 6 minutes ago /bin/sh -c #(nop) ADD file:423cc5b865c0439... 1.17kB
704052b7cc33 6 minutes ago /bin/sh -c #(nop) WORKDIR /tomcat/webapps 0B
05fa6126fbc2 6 minutes ago /bin/sh -c rm -rf $CATALINA_HOME/apache-to... 0B
71238010620c 6 minutes ago /bin/sh -c mv $CATALINA_HOME/apache-tomcat... 13.3MB
8b5270cb598f 6 minutes ago /bin/sh -c $CATALINA_HOME/get_tomcat.sh 13.3MB
8889ce23b8b8 6 minutes ago /bin/sh -c chmod +x $CATALINA_HOME/get_tom... 315B
16bf927a7186 6 minutes ago /bin/sh -c #(nop) ADD file:8e463b6ae893b09... 315B
a4f30cbfb87f 6 minutes ago /bin/sh -c #(nop) WORKDIR /tomcat 0B
238dce716da1 6 minutes ago /bin/sh -c #(nop) ENV CATALINA_HOME=/tomcat 0B
86f576d8387a 6 minutes ago /bin/sh -c mkdir -p /tomcat 0B
a8d71bfb19cf 6 minutes ago /bin/sh -c yum -y update && yum -y install... 165MB
196e0ce0c9fb 4 days ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 4 days ago /bin/sh -c #(nop) LABEL name=CentOS Base ... 0B
<missing> 4 days ago /bin/sh -c #(nop) ADD file:1ed4d1a29d09a63... 197MB
[ghost@pvnp magnolia-base]$
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:
[ghost@pvnp magnolia-base]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bda-1 latest a848ee1c2d8c 5 minutes ago 558MB
centos latest 196e0ce0c9fb 4 days ago 197MB
[ghost@pvnp magnolia-base]$
Notice the difference in size between the base CentOS image, and the one we have now created.
Now I could also rebuilt 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:
[ghost@pvnp magnolia-base]$ docker build -t bda-2 .
Sending build context to Docker daemon 7.68kB
Step 1/14 : FROM centos:latest
---> 196e0ce0c9fb
Step 2/14 : RUN yum -y update && yum -y install java wget && yum clean all
---> Using cache
---> a8d71bfb19cf
Step 3/14 : RUN mkdir -p /tomcat
---> Using cache
---> 86f576d8387a
Step 4/14 : ENV CATALINA_HOME /tomcat
---> Using cache
---> 238dce716da1
Step 5/14 : WORKDIR $CATALINA_HOME
---> Using cache
---> a4f30cbfb87f
Step 6/14 : ADD get_tomcat.sh $CATALINA_HOME
---> Using cache
---> 16bf927a7186
Step 7/14 : RUN chmod +x $CATALINA_HOME/get_tomcat.sh
---> Using cache
---> 8889ce23b8b8
Step 8/14 : RUN $CATALINA_HOME/get_tomcat.sh
---> Using cache
---> 8b5270cb598f
Step 9/14 : RUN mv $CATALINA_HOME/apache-tomcat-8.5.20/* $CATALINA_HOME/
---> Using cache
---> 71238010620c
Step 10/14 : RUN rm -rf $CATALINA_HOME/apache-tomcat-8.5.20
---> Using cache
---> 05fa6126fbc2
Step 11/14 : WORKDIR $CATALINA_HOME/webapps
---> Using cache
---> 704052b7cc33
Step 12/14 : ADD get_latest_magnolia.sh $CATALINA_HOME/webapps
---> Using cache
---> 8039b8abab97
Step 13/14 : RUN chmod +x $CATALINA_HOME/webapps/get_latest_magnolia.sh
---> Using cache
---> c4507fd70520
Step 14/14 : RUN $CATALINA_HOME/webapps/get_latest_magnolia.sh
---> Using cache
---> 50d6a91452f6
Successfully built 50d6a91452f6
Successfully tagged bda-2:latest
[ghost@pvnp magnolia-base]$
See how it is "using cache" for all those steps? This took no time at all to run.