1

I am a newbie to docker, I wanted to run a Java web application which takes name and mail and stores it in a MySQL dB now my doubt is how can I use a MySQL image and where I need to mention dB config in my app and how to make these app and dB container to run on tomcat server .is it possible to upload this entire image in docker hub to run on another host which pulls this image and can run this app successfully ..

I want to dockerize my name and mail application so that I can convert into an image so that any host can pull that image and run the app without any dependencies

cks
  • 29
  • 1
  • 6

1 Answers1

0

you are talking about different things.

The image has its own instance on the port, which you mark it to be opened - it is like virtual machine - kinda like... And Java Spring app are just using this port to contact with your DB (look, how application.properties file should be written) and especially pom.xml, where you also should specify maven dependency for example for liquibase and pass the host url to it.

Have you ever connected to DB via IntelliJ? - retorical question

Here you have at least 4 questions... In my opinion you misunderstand the whole idea.

Read this at the beggining: https://stackoverflow.com/a/2840358/6237822

This is a small thing about docker: cant connect to postgres db - docker swarm - I think you should write one, very similiar for your Mysql

I also encourage you for lecturing: https://docs.docker.com/get-started/

xross
  • 597
  • 4
  • 9
  • 25
  • 1
    Can I pull the MySQL image from docker hub an mention the dB properties in my app – cks Nov 16 '17 at 12:20
  • you have to have some machine for it to be working - for example linux server, windows server, localmachine (only up, when you take it up). Docker hub is like a storage, when you can exchange an image (in your case there are a lot of ready ones MySql images - I suppose) - download it onto your machine with ready dockerfile. Thanks to it, you can only run it in a very short time. This wouldnt store your data. It is not supposed to. https://docs.docker.com/docker-hub/ read the topic: "Work with Docker Hub image repositories" – xross Nov 16 '17 at 12:25
  • 1
    I just want to run the app without any dependencies needed to be configured like MySQL tomcat server etc I do not need my data to be transferred – cks Nov 16 '17 at 12:29
  • you can freely modify that - all the settings should me in config files (mainly in dockerfile) – xross Nov 16 '17 at 12:30
  • 1
    Can u provide any working example which gives me some head start – cks Nov 16 '17 at 12:32
  • Sorry check for file *.yml - I worked quite long ago and didnt remember – xross Nov 16 '17 at 12:32
  • yeah, here you go https://docs.docker.com/samples/library/mysql/ – xross Nov 16 '17 at 12:33
  • there is all you need to start your docker image for MySQL (and also I found there is smth such as link to your app) – xross Nov 16 '17 at 12:34
  • If this is, what you need, please give me an upvote – xross Nov 16 '17 at 12:36