-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to deploy the application using docker compose #1091
Comments
@betanzos the problem is:
The container can't access MySQL. There should be a problem with the network configuration, or the MySQL service is not running when EHRServer is executed. |
This is because the app container is trying to connect to the database inside itself:
There is no problem with this. The depends_on:
- db
I able to access the mysql container ( The problem the definition of |
@betanzos to run this dockerfile, the database is external, there is no configuration of mysql inside the image. To access the host database, it needs to run with network=host parameter. The CATALINA... line is OK. Please check https://twitter.com/ppazos/status/1332859632948301828?s=20 and https://youtu.be/o-XMb7lGLio For me the dockerfile works OK. Though I can't run the docker-compose, there is an issue connecting to the db container. |
Docker images are almost always used with orchestration softwares like Kubernetes or Docker Swarm. This kind of software have the full control about containers lifecycle, including network configuration. So, IMO is a really bad idea to build a Docker image which force clients to use a predefined network design (network=host). But, let's put an example...what if instead having the database on the same machine as Docker we have an specific server for it (accessible over the network)? In this case our Docker image don't work because we assume that database would be running on the same machine as Docker and we define the JDBC URL with 127.0.0.1 (from Dockerfile -DdataSource.url=jdbc:mysql://127.0.0.1:3306/ehrserver2). The above case is (almost) the same when we use the If you want to run your database in the host machine, isn't necessary to put the datasource definition inside the image, using env vars at runtime is enough:
Otherwise we can only connect to a database on the host machine unless we override the
For sure you are having this same problem. Try with this in
|
@betanzos the current dockerfile doesn't work that way. My knowledge about docker and it's ecosystem is limited. You are welcome to contribute a fully working configuration. I can test it and add it to the repo. Also the current docker compose file is broken IMO. You are also welcome to contribute to that one. As a reference https://www.youtube.com/watch?v=o-XMb7lGLio |
@betanzos closing this one until someone wants to contribute a compose file that works. |
Hi @ppazos, sorry for the late reply but I hardly had time to dedicate to this matter. Please, check my PR about this issue (#1092). The current compose file is good and doesn't need any kind of tweak, the root cause of this problem is in the Dockerfile that forces to have the database running on IP 127.0.0.1 (localhost) and this is wrong. |
Thanks @betanzos I have checked the PR for me it doesn't work without the parameters. Also the current dockerfile is what I was able to do that works, I'm not saying that is the best way of doing it. But until I get help from someone that knows docker better than me, I'm not able to change the current dockerfile. |
@ppazos you have tried to run use the Dockerfile from this PR and run the image in the way I commented?
I have been reviewing this topic and I think the proposed Dockerfile is enough good for any environment configuration. |
@betanzos I managed to create a docker-compose file that works creating a mysql container and a tomcat container, please check it in the docker-compose folder, I think it's better than the Dockerfile run |
@betanzos from what I can search online it has to do with the volumes inside the Can you send an ls of your build/libs folder? Also please check folder permissions on docker-compose/* Another thing to try is docker-compose --verbose up I didn't use -d to run it:
|
I think so but, for me, all directories used to mount volumes have the right permissions.
There are no differences in using the
|
@betanzos here someone mentions it could be because of the relative paths in volumes https://stackoverflow.com/questions/67239635/cannot-create-container-for-service-mysql-not-a-directory and suggests to use $PWD instead I will try to run it verbose on my machine to see if I get the same output. |
Works for me! |
Bug description
If we try to deploy this app on Docker using the
docker-compose
command and thedocker-compose.yml
file from this repo, we get the following errors:The origin of this is in the
Dockerfile
used to build the docker image. Line 15 define a static value for ths env varCATALINA_OPTS
that override the datasource definition with wrong values.Container's logs show us this:
The recently announced official docker image (version 2.3) has also been affected by this issue.
Full log
Solution
Since datasource configuration resides in grails-app/conf/application.yml (or in /app/config.yml inside the container) and can be easily overridden using volumes or environment variables,
CATALINA_OPTS
definition should be dropped out fromDockerfile
.Temporal solution
In order to fix this, we must set an empty value for the CATALINA_OPTS env var. Below an example with
docker-compose
.Reproduction steps
The text was updated successfully, but these errors were encountered: