Video recording from Docker for Java Developers webinar is now available:
Here are answers to the questions asked:
-
What do you think of Kubernetes compared to Docker and Docker Swarm? Kubernetes or Docker Swarm? Which way to go?
It depends 😉
Docker Swarm has a much simpler learning curve as opposed to Kubernetes. Kubernetes is very opinionated but can be very powerful once you understand how it works.
Some of the points worth considering are:
- Easy to setup/start
- Need to learn new concepts or aligned with Docker
- How can it be aligned with your existing workflow
- Single or multiple master
- Support for multiple clouds
- Cluster across multiple clouds
- Dynamic scaling up/down
- Rescheduling containers on node/container failure
- Pluggable scheduler strategies (if you want to go fancy)
- Service discovery
- Persistent volumes
If this question was asked a few months ago, then Kubernetes would have been the obvious choice. But Docker Swarm is really cranking out releases and features and has caught up well. Check out Docker Swarm Exceeds Kubernetes Performance at Scale. Hackernews has some interesting discussion on this topic as well. Also read Evaluating Container Platforms at Scale.
In addition, you should also look at Mesos+Marathon or DC/OS.
Here are some blogs to get started:
- Couchbase cluster on Docker Swarm using Compose and Machine
- Kubernetes Cluster on Google Cloud and Expose Couchbase Service
- Kubernetes Cluster on Amazon and Expose Couchbase Service
- Couchbase on DC/OS and Amazon
-
What is the best practice to develop against a docker WildFly container if you do not want to bundle the WAR file after each change but use an exploded archive instead in order to just repackage static resources for example?
Docker allows mapping directories on your filesystem as volumes in the container. This can be used to develop your application against a WildFly container without the need to be bundle the WAR with each change. This is explained in more detail at Deploy to WildFly Docker from Eclipse. - Does IntelliJ Idea support native docker on Mac OS/Windows?
Andrey: Not yet but it’s on the roadmap. -
What are pros and cons of providing environment variable vs link like consul:consul?
Docker Links are legacy and so environment variables and Docker Networking are the recommended way to build any new applications. Read more details in another answer below.
-
How do we attach a debugger to a Java process running in a container?
Read this great blog entry by Daniel Bryant on Debugging Java Applications running in Docker.
-
What is the relation between Docker and Vagrant? Can both work together? Is docker a substitute of Vagrant?
Docker and Vagrant solve different problems.
Vagrant allows you to provision Virtual Machines independent of the host machine. This is done by using a hypervisor, such as VirtualBox. The definition for the VM is stored in a
Vagrantfile
, and defines how to setup the VM and what scripts to provision the environment. These VMs can be created on Linux, Windows or Mac.Docker allows you to create containers. It is a native Linux technology based upon
lxc
and coming to Windows Server 2016 this Summer. Docker for Mac provides development environment for Mac.If you need to provision a Docker Engine, then you can create a
Vagrantfile
that provisions Ubuntu or CentOS using Virtual Box. Then runapt get
oryum install
scripts to install Docker Engine. If a new version of Docker Engine is available, then you are responsible for updating the Vagrant image as well, or run the script again.Another option is to use Docker Machine and use VirtualBox driver to create a machine that will have Docker Engine installed. The
docker-machine
script has commands like upgrade that simply upgrades the Docker Engine.Some more interesting discussions are at StackOverflow and Quora.
To make this whole equation further interesting, Vagrant can be backed by Docker containers instead of VMs!
-
Docker tool window is missing in my IntelliJ IDEA 15. Plugin is installed.
Andrey: The separate tool window was added in 2016.1. Before that Docker was a part of the Application Servers tool window.
-
Is it possible to change index.jsp and see the change in the browser without building the image again? In the spirit of update resources action in IntelliJ IDEA?
Andrey: Sounds like a great idea. Please submit it as a feature request to tracker: https://youtrack.jetbrains.
com/issues/IDEA. -
Is there a performance increase for using xhyve/Hyper-V over VirtualBox?
Docker for Mac runs Docker Engine in Alpine Linux distribution on top of xhyve Virtual Machine for Mac OS X or on Hyper-V on Windows. xhyve is built onHypervisor.framework
in OS X 10.10+. Some of the primary advantages of using a native technology as opposed to a Type 2 hypervisor is native look-and-feel, better performance, and better volume management.Read more details in (3-months old blog) xhyve vs VirtualBox driver benchmarks. This area is fast evolving and keep an eye on blog.docker.com for more details.
-
In Docker Compose, how do I update only one container, does it lose the “link” do I need to redeploy everything?
Docker Links are now legacy. It’s highly recommended to migrate your application to use Docker Networking. The main difference between Links and Networking are:
- Connect containers to each other across different physical or virtual hosts
- Containers using Networking can be easily stopped, started and restarted without disrupting the connections to other containers
- You don’t need to create a container before you can link to it. With Networking containers be created in any order and discover each other using their container names
-
How can one expose a host port to a container running on the host?
Ports in a container are exposed on the host using
-p
with docker run. Ports on the host can be accessed using<host-ip>:<port>
directly. -
Official Java Docker image (OpenJDK-based) is not TCK certified. What do you suggest in this case?
OpenJDK is the Reference Implementation of Java SE and so is TCK compliant. Official Java Docker image is based on OpenJDK.Azul Systems provide commercial support for OpenJDK. Another option is to use OpenJDK images available from Azul systems. These are fully tested and compatibility verified builds of the latest versions of the OpenJDK 8, 7, and 6 platforms.Oracle publishes Dockerfile for JDK but don’t publish the images. Note that this definition uses
oraclelinux:latest
as the base image and you may want to useubuntu
,centos
oralpine
. In this case, you can create your own Dockerfile.Running Java on Docker? You’re breaking the law provides a good summary of why Oracle JDK-based image should not be pushed to Docker Hub.
-
How do you have a container with WildFly use a container with the db on another server?
Docker Links are legacy and only allow containers to talk to each on the same host. The recommended way for two containers to communicate is using Docker Networks.By default, Docker Swarm cluster creates an overlay network that allows multiple containers to talk across hosts. Multi-container and multi-host applications using WildFly and Couchbase shows how to connect WildFly with Couchbase where each container is running on two separate hosts on a Docker Swarm cluster.Here is the Compose file for reference:
1234567891011121314151617mycouchbase:container_name: "db"image: couchbase/serverports:- 8091:8091- 8092:8092- 8093:8093- 11210:11210mywildfly:image: arungupta/wildfly-adminenvironment:- COUCHBASE_URI=dbports:- 8080:8080- 9990:9990
Here are some more references:
- Learn all about IntelliJ and Docker at jetbrains.com/idea/docker/
- Self-paced Docker for Java Developers workshop
- Docker for Java developers Introductory slides
- Script for Docker and IntelliJ demo shown in the video
- Docker Docs
- Couchbase on Containers
Source: http://blog.couchbase.com/2016/may/docker-java-intellij-idea-webinar-replay