You can not use localhost/127.0.0.1 inside a container to connect to another, as that is the localhost within the container, not localhost of the node/host.
Use the service name from docker-compose.yml instead, Docker provides an internal DNS service to resolve that to the container ip.
"Output": "Enter password: \u0007mysqladmin: connect to server at 'mysqldb' failed\nerror: 'Access denied for user 'myadmin'@'172.18.0.2' (using password: NO)'\n"
If this was not your suggestion to resolve the issue, kindly advise further.
Using localhost in healtchecks that checks the processes in the container is possible, but I donât see how you set the variable in the healtcheck. The one that you set for the container will not be available there for two reasons.
The variable will be interpreted when the yaml is parsed so it will be empty unless you have an env variable on the host or in a dot env file.
CMD will not run a shell so you wonât have environment variables even if you pass the variable correctly. CMD-SHELL would run the commands in the containerâs default shell: Services top-level elements | Docker Docs
The error message is pretty clear by the way: âusing password: NOâ. Since you intended to pass a password, that should have been suspicious.
If you want the variable to be passed to the shell (using CMD-SHELL), you can use a double dollar like this:
If you use a recent version of Docker Compose and you didnât set a variable on the host or in a dot env file, you should have gotten a warning saying the environment variable is not set.
@bluepuma77, @rimelek . I appreciate your help. So, this configuration sort of worked. I added database configs from application.properties into the environment properties of the service container in JSON format.