Who are better suited to explain what Docker is then the creators of Docker themselves?
So here is how they describe Docker on their site: Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud.
Containers vs. Virtual Machines
Now, how do containers differ from virtual machines and why should we prefer containers? As depicted in the image below, in the case of virtual machines, multiple guest OS’s are ran on top of the host OS using a (type 2) hypervisor. Every guest OS includes all necessary binaries and libraries.
In the case of containers, multiple containers are ran on top of the corresponding images on top of the host OS using a container engine*. All necessary binaries and libraries are included in the image and all containers created on top of a image will have these available.
This means that a container solution use far less disk space since there are not multiple full blown OS’s necessary. In addition even the binaries and libraries are shared between multiple containers created of the same image.
Another advantage of not having guest OS’s is boot time. The boot time of a virtual machine is for a significant part the boot time of the guest OS. While for containers the “boot” time is mainly the time it takes your application to start up.
Why use Docker?
- Run tests in the same (or a very similar) environment as production.
- Same environment e.g. every container has all the needed environment variables.
- Update the environment once and ship the update to all team members e.g. via a Docker image or GIT (Dockerfile, etc.).
- Automated deployments can be facilitated using Docker images.
- Run tests without the, normally necessary, clean-up afterwards, which saves time.
- An environment to develop/experiment in for which it does not matter if it breaks.
- Run one application per environment i.e., no interference of (Oracle) products required by multiple applications.
- Easily change where applications are hosted i.e. no tedious initial setup.
- Save hosting costs by hosting multiple applications on the same machine.
- Each container has its own filesystem. This allows you to run multiple applications that use the same filesystem location, which would otherwise interfere with each other.
Low resource usage
- Especially in the case of a Linux host environment, since resources of the host operating system are reused. However, also on Windows/MacOSX with e.g. the Boot2Docker virtual machine, since it is very light weight.
- Every container (instance) is only a small layer on top the image (blueprint).
Have the same resources available for all developers
- Oracle offers official Oracle Linux Docker images, available on the Docker Hub .
- Also, there are Docker images for Oracle WebLogic  and Oracle Coherence  which one could use and reduce the number of (difficult) installations.
Perform difficult tasks with only a few commands
- Please, see the next section.
How to use Docker
First, one needs to describe how the Docker image should be build, i.e. specify the base image (e.g. Oracle Linux 6); environment variables; binaries and libraries that need to be installed; and configuration. This is done by means of a Dockerfile.
Next, the Docker image can be build using the build command, like this:
docker build -t image-name /path/to/build-context/. In this case the
build-context directory would contain the Dockerfile.
Finally, to create and run a Docker container use the run command, like this:
docker run -p 8080:8080 -v /path/on/host:/mount-point/inside/container --name container-name image-name. The previous command uses the earlier created image called:
image-name and creates a container called
container-name. Additionally, port 8080 inside the container is forwarded to port 8080 on the host and a directory, called
/path/on/host, on the host is mounted inside the container on the mount-point called
* Docker container technology is, currently, based on the Linux OS. Docker containers can be run on Windows/MacOSX with e.g. the Boot2Docker virtual machine, which itself is very light weight.