How to use docker-compose with with tomcat - docker

I am trying to set up a tomcat server. I need to edit some of the files within the docker container and want to know is there a way I can save these files so that if we're to do docker-compose up again on another machine it was used the edited files? One idea I had was to take the tomcat image to modify it then use the custom image in docker-compose. Or am I just overthinking this and having the edit those files manually is something that I just have to do. Also, I am relatively new to docker so any advice would be helpful.

Using your own custom version of the tomcat image is the simplest way to configure it to your specifications.
See for instance, as example of configurations:
"Docker tomcat editing configuration files through dockerfile"
"How to change user config in docker tomcat 8?"

Related

How to modify the configuration of the database in docker of opengauss

Recently, I was trying to deploy the opengauss database using docker, and I saw that this docker was released by your company.
Currently encountered the following two problems:
The corresponding database configuration file was not found: “hab.conf or postgreq.conf”, where is the location of this file in the docker image? If not, can it be gs_*modified by tools.
When the database in docker is started and then restarted, the docker image will be launched, and there are no parameters linked to the configuration file in the docker image, so there is no way to modify the configuration file of the database. At present, the solution I think of is to “running container”directly “commit & save” the modified image into a new image. Is this the only solution?
.hba.conf or postgreq.conf is here
/var/lib/opengauss/data, support to use gs_guc to modify parameters.
.After changing the parameters that require database restart to take effect, just restart the container directly.
.You can also do persistence if you want, specify it through the -v parameter when running.
-v /enmotech/opengauss:/var/lib/opengauss

How to extract docker-compose file from running docker start

I have docker stack started with docker stack deploy --compose-file ...
and later manually edited via Docker Portainer UI.
I'd like to write a script that updates the docker image tag of one of the services.
To do that I need to "download" the latest "docker-compose" stack definition however I cannot find the appropriate docker command.
I do know that the best would be to stop changing stack manually and rely on its definition stored in git but unfortunately, it is not up to me.
Please point me to the appropriate docker command or confirm that it is not available.
As far as i know there is no command you could get the compose file from the running container directly. At least not implemented out of the box in docker. You could try to parse all the relevant information from docker inspect and few other commands to list/inspect all relevant objects?.
I have once came across the similar situation where we had a running container but no run/compose command which we needed to update. At the time (roughly a year ago) i found and used docker-autocompose which did very good job. We only had to manually verify and adjust few things,but it got all the difficult parts with run parameters done for us.
It could help in your case to automate it if your compose configs are simple enough.
But if you wanted to fully automate it to mimic CD, then i would not recommend the approach above. In that case i would check if you could use portainer api as #LinFelix recommended. Or store compose files somewhere - prepared with parameters ($IMAGE_TAG) (git/on server) so you can then generate temporary compose files with all configuration and then remove the current one.

where are indexing configuration in OpenGrok docker image?

I am trying to setup an OpenGrok instance from a docker image. By default svn indexer inside the image is checking for new repositories in 10 minutes.
I need to change this configuration. From where exactly I can change this.
As soon as I posted this I found the related files inside docker container at /scripts.
Here REINDEX variable is defined in start.sh script.

docker containers application servers and application

Experts.
I am newbie to Docker. Started exploring the docker and its tools and successfully created the docker setup [using toolbox in win 7] and created a websphere-liberty image and deployed my spring boot application as war [needed as war as per my company requirement]. Also linked to eclipse, so I can develop and run from eclipse and the application runs in docker container. I am in the process of creating an app image [war] for my application.
Now my question.
Architecturally what is the good approach and need help on how to do.
Create one container with Websphere-liberty image and manually add the application image in that.
Create two containers, one having Websphere-liberty and another with image of my application and make the application run on the server.
or any other good approaches ?
In my opinion, you should inherit from this image (https://hub.docker.com/_/websphere-liberty/) and COPY the war to the new image.
So if by "manually" you mean by using a Dockerfile, then yes solution number 1, otherwise just do what I explained to you.
Note: Do not add the war-file by using a volume like explained on the websphere-liberty image page... This is bad practice in my opinion and might only be suitable for dev, if suitable at all...

Should I create multiple Dockerfile's for parts of my webapp?

I cannot get the idea of connecting parts of a webapp via Dockerfile's.
Say, I need Postgres server, Golang compiler, nginx instance and something else.
I want to have a Dockerfile that describes all these dependencies and which I can deploy somewhere, then create an image and run a container from it.
Is it correct that I can put everything in one Dockerfile or should I create a separate Dockerfile for each dependency?
If I need to create a Dockerfile for each dependency, what's the correct way to create a merged image from them all and make all the parts work inside one container?
The current best practice is to have a single container perform one function. This means that you would have one container for ngnix and another for your app.. Each could be defined by their own dockerfile. Then to tie them all together, you would use docker-compose to define the dependencies between them.
A dockerfile is your docker image. One dockerfile for each image you build and push to a docker register. There are no rules as to how many images you manage, but it does take effort to manage an image.
You shouldn't need to build your own docker images for things like Postgres, Nginx, Golang, etc.. etc.. as there are many official images already published. They are configurable, easy to consume and can be often be run as just a CLI command.
Go to the page for a docker image and read the documentation. It often examples what mounts it supports, what ports it exposes and what you need to do to get it running.
Here's nginx:
https://hub.docker.com/_/nginx/
You use docker-compose to connect together multiple docker images. It makes it easy to docker-compose up an entire server stack with one command.
How to use docker-compose is like trying to explain how to use docker. It's a big topic, but I'll address the key point of your question.
Say, I need Postgres server, Golang compiler, nginx instance and something else. I want to have a Dockerfile that describes all these dependencies and which I can deploy somewhere, then create an image and run a container from it.
No, you don't describe those things with a dockerfile. Here's the problem in trying to answer your question. You might not need a dockerfile at all!.
Without knowing the specific details of what you're trying to build we can't tell you if you need your own docker images or how many.
You can for example; deploy a running LAMP server using nothing but published docker images from the docker hub. You would just mount the folder with your PHP source code and you're done.
So the key here is that you need to learn how to use docker-compose. Only after learning what it can not do will you know what work is left for you to do to fill in the gaps.
It's better to come back to stackoverflow with specific questions like "how do I run the Golang compiler on the command line via docker"

Resources