How to containerize a simple Java app with H2 database - docker

I wrote a simple Java Web application based on Spring with H2 database. Now I want to containerise it.
I was thinking about using docker. Is that a good choice. Would there be some other tool ?
Honestly I do not know advantages of docker. I mean Java is platform independent anyway. So what makes it appealling of using Docker ?
What I also understand if you have many many containers you need a tool like Kubernetes to manage all these containers.
Thanks for your help.

I recommend reading Docker Get Started, this will answer all your questions.
If you need a quick example of a dockerized Spring application you can check this one or read Spring Boot with Docker guide.

Related

Deploy a monolithic and Microservices in same Docker container

Can I deploy both an asp.net Monolithic application and a Microservices application in the Same Docker Container? How to do it ?
Usually, this is not advisable, the better way is deploying two docker containers and possibly sharing a network (or other resources) between them
However, it's still possible to achieve by using one of two ways:
Make an entry point to be a script that starts all the required processes in one container.
Use tools like supervisord
A much more detailed explanation can be found here.

What Rebus transport should I use for running in Docker, but not Azure

I try to set up a Docker container for an ASP.NET Core/net47 application that uses Rebus with MSMQ. But it doesn't seem to be possible to use MSMQ with Docker.
The application is not hosted on Azure - and it does have to communicate with external services via the bus, and they do not share a database - so it can't be SQL Server transport either, I guess.
So I wonder... what I my options with Rebus?
Well.... I guess your best option at the moment is to pull down a Docker image with RabbitMQ in it.
But since I'm not a Docker kind of guy, I cannot give you any further instructions besides that.
Since this question reaches beyond Rebus and far into Docker territory, it would be awesome if someone well-versed in Docker stuff would chime in.

What cluster can I user in my case?

I am going to run my golang app on oracle linux 7 server, I am going to use kubernetes using docker containers. What kind of kubernetes cluster can I use? Can you introduce me some short tutorial for deploying my app. Thank you!
For short introduction I think this blog post is really good. It will tell you basics and what you should know at start https://www.digitalocean.com/community/tutorials/an-introduction-to-kubernetes
But if you want to get deeper, start reading:
https://kubernetes.io/
For a start, use minkube, which allow you to run kubernetes locally https://github.com/kubernetes/minikube

Setup commands for Mesos and Kubernetes on Docker?

When trying to move a web container (Tomcat) to the latest technologies for better growth and support, I came across this blog. This part seems ideal for my needs:
... we are also incorporating Kubernetes into Mesos to manage the deployment of Docker workloads. Together, we provide customers with a commercial-grade, highly-available and production-ready compute fabric.
Now, how to setup a local test environment to try this out? All these technologies seem interchangable! I can run docker on mesos, mesos on docker, etc etc etc. Prepackaged instances allow me to run on others Clouds. Other videos also make this seem great! Running out on the cloud is not a viable (allowed) option for me. Unfortunately, I can not find 'instructions' on how to setup the configuration described/marketed/advertised.
If I am new to these technologies, and know there will be a learning curve, is there a way to get initialized for doing such a "simple task": running a tomcat container on a Docker machine that is running Mesos/Kubernetes? That is, without spending days trying to learn and figure out each individual part! This is the picture from the blog site referenced:
Assuming that I "only" know how to create a docker container(s) (for say, centos-7). What commands, in what order, (i.e. the secret 'code') do I need to use to configure small (2 or 3) local environment to try out running Tomcat?
Although I searched quite a bit, apparently not enough! Someone pointed me to this:
https://github.com/kubernetes/kubernetes/blob/master/docs/getting-started-guides/mesos-docker.md
which is pretty close to exactly what I was looking for.

How Docker can be used for multi-layered application?

I am trying to understand how docker can be used to dockerize multilayered application.
My tomcat application needs mongodb, mysql, redis, solr and rabbitmq. I am playing with Docker for couple of weeks now. I am able to install and use mongo/mysql containers. But I am not getting how can I completely ship application using Docker. I have few questions.
How should the images be. Should I have one image that has all the components installed or have separate images (like one for tomcat, one for mongo, one for mysql etc) and start those containers using a bash script outside of docker.
What is the docker way of maintaining multiple containers at once. Meaning say I have multiple containers (like mongo, mysql, tomcat etc...) that needs to be worked together to run my application, Is there any inbuilt way of dealing this so that one command/script does this?
Suppose I dockerize my application, how can i manage various routine tasks that need to be performed like incremental code deployment, database patches etc. Currently we are using vagrant, we also use fabric along with vagrant for various tasks.Like after vagrant up we use fab tasks for all kind of routine things like code deployment, db refresh, adding volumes, start/stop services etc. What would be the docker's way of doing this?
With Vagrant if VM crashes due to High CPU etc. host system is not affected. But I see docker is eating up lot of host resources. Can we put limits for that say not more than one cpu core for that container etc..?
Because we use vagrant, most of the questions above are in that context. When started with docker I thought docker as a kind of visualization technology that can be a replacement for our huge Vagrant based infra. Please correct me if I am wrong?
I advise you to look at docker-compose:
you'll be able to define an architecture of your application
you can then easily build it and run it (with one command)
pretty much same setup for dev and prod
For microservices, composition etc I won't repost on this.
For containet resource allocation:
Docker run has various resource control options (using google cgroups) see my gist here
https://gist.github.com/afolarin/15d12a476e40c173bf5f

Resources