Spring boot debug in Eclipse - eclipse

I would like to debug my Spring boot application using the remote debugger in Eclipse.
Here is my docker-compose.yml
version: "3.8"
services:
mysqldb:
image: mysql:5.7
restart: unless-stopped
environment:
- MYSQL_DATABASE=root
- MYSQL_ROOT_PASSWORD=leblanc
volumes:
- db:/var/lib/mysql
gomoku-web:
image: gomoku-web:0.0.1-SNAPSHOT
depends_on:
- mysqldb
ports:
- 8080:8080
- 8888:8888
environment:
SPRING_APPLICATION_JSON: '{
"spring.datasource.url" : "jdbc:mysql://mysqldb:3306/root?useSSL=false",
"spring.datasource.username" : "root",
"spring.datasource.password" : "leblanc",
"spring.jpa.properties.hibernate.dialect" : "org.hibernate.dialect.MySQL5Dialect",
"spring.jpa.hibernate.ddl-auto" : "update",
"fr.leblanc.gomoku.engineUrl" : "http://gomoku-engine:9000"
}'
CATALINA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8888"
volumes:
- .m2:/root/.m2
stdin_open: true
tty: true
gomoku-engine:
image: gomoku-engine:0.0.1-SNAPSHOT
ports:
- 9000:9000
stdin_open: true
tty: true
volumes:
db:
In Eclipse, I created a Remote Java Application with Host "localhost" and port "8888" but when I try to launch it, it says :
Failed to connect to remote VM
com.sun.jdi.connect.spi.ClosedConnectionException
Am I missing something ? Thank you!

I fixed my problem
I needed to replace
CATALINA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8888"
with
JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:8888,server=y,suspend=n"

Related

SonarQube cannot access PostgresDB

I am trying to set up SonarQube self-hosted using docker with docker-compose. To use SonarQube via HTTPS I am using nginx as reverse proxy and the jrcs/letsencrypt-nginx-proxy-companion to handle the SSL-Certificate.
Now I have configured SonarQube using the following docker-compose.yml:
version: '3'
networks:
ext:
int:
volumes:
certs:
vhosts:
html:
postgresql_data:
postgresql:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:
services:
nginxproxy:
image: jwilder/nginx-proxy:alpine
container_name: nginxproxy
hostname: nginxproxy
restart:
unless-stopped
networks:
- ext
volumes:
- certs:/etc/nginx/certs:ro
- vhosts:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
- ./config/my_proxy.conf:/etc/nginx/conf.d/myproxy.conf:ro
ports:
- 80:80
- 443:443
labels:
- com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy
environment:
- SSL_POLICY=Mozilla-Intermediate
nginxproxy_comp:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: nginxproxy_comp
hostname: nginxproxy_comp
restart:
unless-stopped
depends_on:
- nginxproxy
networks:
- ext
volumes:
- certs:/etc/nginx/certs
- vhosts:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
sonarqube:
image: sonarqube:community
container_name: sonarqube
hostname: sonarqube
depends_on:
- db
restart:
unless-stopped
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_logs:/opt/sonarqube/logs
- sonarqube_extensions:/opt/sonarqube/extensions
environment:
- SONAR_JDBC_URL=jdbc:postgresql://localhost:5432/sonarqube
- SONAR_JDBC_USER=sonarqube
- SONAR_JDBC_PASSWORD=sonarqube
networks:
- int
ports:
- 9000:9000
db:
image: postgres:12
container_name: db
hostname: db
networks:
- int
ports:
- 5432:5432
environment:
- POSTGRES_USER=sonarqube
- POSTGRES_PASSWORD=sonarqube
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
restart:
unless-stopped
Now when I try to start docker-compose, SonarQube is giving me the following Error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdk.internal.loader.ClassLoaders$AppClassLoader#277050dc-org.sonar.db.DefaultDatabase': Initialization of bean failed; nested exception is java.lang.IllegalStateException: Fail to connect to database
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Can anyone please tell me what i did wrong?
What I see here is the incorrect JDBC URL. It must below
SONARQUBE_JDBC_URL=jdbc:postgresql://db:5432/sonarqube
Since you have network between containers DB accessible via db
Also, under SonarQube container add below as well
privileged: true
Check one of my sample project in GitHub
https://github.com/shamith234/sonarqube-9.5-postgres-docker/blob/master/docker-compose.yml

docker-compose does not create network

iam trying to create containers with docker-compose. My problem is, that the network is not created and the services end up in the default network. My docker-compose.yml is following:
version: "3"
services:
Nebula_pgadmin:
image: nebula
environment:
- SOCAT_PORT=80
- SOCAT_SERVICE=pgadmin
volumes:
- ./Nebula_pgadmin.test.dev.key:/etc/nebula/host.key
- ./Nebula_pgadmin.test.dev.crt:/etc/nebula/host.crt
- /opt/nebula-v1.5.2-test/nebula:/opt/nebula/nebula
cap_add:
- NET_ADMIN
privileged: true
restart : unless-stopped
networks:
- nebula
Nebula_test:
image: nebula
environment:
- SOCAT_PORT=400
- SOCAT_SERVICE=test
volumes:
- ./Nebula_test.test.dev.key:/etc/nebula/host.key
- ./Nebula_test.test.dev.crt:/etc/nebula/host.crt
- /opt/nebula-v1.5.2-test/nebula:/opt/nebula/nebula
cap_add:
- NET_ADMIN
privileged: true
restart : unless-stopped
networks:
- nebula
networks:
nebula:
Iam just starting to use docker and can not figure out the problem.
Thx!

PostgreSQL + metabase connection refused

I am trying to configure postgres to run with springboot and metabase. Each service is running separately alone but when I try to put the 3 together in a docker-compose file, I am getting the following error :
Caused by: org.postgresql.util.PSQLException: Connection to 0.0.0.0:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
metabase-container | at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:303)
However, I have mapped the port 5432 of db to the port 5432 of the metabase container.
And yet, It doesn't seem to work. Any help on this issue? (please find my docker-compose file below)
version: '2'
services:
spring:
image: 'realtime:latest'
container_name: spring
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/compose-postgres
- SPRING_DATASOURCE_USERNAME=compose-postgres
- SPRING_DATASOURCE_PASSWORD=same
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
volumes:
- /home/vagrant/valorisation-2.0:/app
command: ["java", "-jar", "rtv-1.jar"]
mem_limit: 10g
mem_reservation: 10g
ports:
- "8079:8080"
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=compose-postgres
- POSTGRES_PASSWORD=********
- METABASE_PASSWORD=same
ports:
- "8078:5432"
- "54320:5432"
metabase:
container_name: metabase-container
restart: "always"
image: metabase/metabase
ports:
- "3000:3000"
- "5432:5432"
environment:
- MB_DB_TYPE=postgres
- MB_DB_DBNAME=db
- MB_DB_PORT=5432
- MB_DB_USER=compose-postgres
- MB_DB_PASS=same
- MB_DB_HOST=0.0.0.0
- MB_ENCRYPTION_SECRET_KEY=********
Try changing MB_DB_HOST in the metabase environmental variables from 0.0.0.0 to db.
The subtilty I hadn't understood is that all the services are in the same network. Hence, deleting port forwarding (which exposes the services to outside components but is irrelevant for communication within the container) between the services and changing the Metabase configuration file does the job. Here is the modified docker-compose.yml file :
version: '2'
services:
spring:
image: 'realtime:latest'
container_name: spring
depends_on:
- db
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/compose-postgres
- SPRING_DATASOURCE_USERNAME=********
- SPRING_DATASOURCE_PASSWORD=**********
- SPRING_JPA_HIBERNATE_DDL_AUTO=update
volumes:
- /home/vagrant/valorisation-2.0:/app
command: ["java", "-jar", "rtv-1.jar"]
mem_limit: 10g
mem_reservation: 10g
ports:
- "8079:8080"
db:
image: 'postgres:13.1-alpine'
container_name: db
environment:
- POSTGRES_USER=compose-postgres
- POSTGRES_PASSWORD=compose-postgres
- METABASE_PASSWORD=compose-postgres
ports:
- "8078:5432"
metabase:
container_name: metabase-container
depends_on:
- db
restart: "always"
image: metabase/metabase
ports:
- "3000:3000"
environment:
- MB_DB_TYPE=postgres
- MB_DB_DBNAME=********
- MB_DB_PORT=5432
- MB_DB_USER=************
- MB_DB_PASS=compose-postgres
- MB_DB_HOST=db
- MB_ENCRYPTION_SECRET_KEY=***********

How to connect to dbeaver using Docker in Windows 10 environment?

I am studying docker.
but i have a issue. because I can't see the db using dbeaver.
when you are using previous Linux, i could write the same and then it is working
but now i use window so not working
i made docker compose file
version: "3.8"
services:
backend:
build:
context: .
dockerfile: Dockerfile
# network: auth-module
volumes:
- ./src:/server/src
ports:
- 4000:4000
env_file:
- ./.env.dev
# command: "npm run prod"
links:
- postgres
postgres:
image: postgres:12
environment:
POSTGRES_USERNAME: "postgres"
POSTGRES_DB: "auth"
POSTGRES_PASSWORD: "1234"
ports:
- 5432:5432
networks:
default:
external:
name: auth-module
What is the problem?
and How to fix it?

Making migrations for hasura container and running console

I want to make a developer offline space to develop my database with hasura
I know the existence of the container with the tag cli-migrations, but the command:
hasura-cli console
doesn't work for accessing outside of the container.
My configuration for the docker-compose.yml is:
version: '3'
services:
hasura:
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://[some pass]:[some user]#db:5432/[some db]
- HASURA_GRAPHQL_ENABLE_CONSOLE=false
image: hasura/graphql-engine:v1.0.0-rc.1.cli-migrations
container_name: hasura
volumes:
- ./hasura-migrations:/hasura-migrations
networks:
- hasura-db
ports:
- "8081:8080"
- "8082:8081"
restart: always
command: hasura-cli console --console-port 8081 --no-browser
db:
environment:
- POSTGRES_USER=[some user]
- POSTGRES_PASSWORD=[some pass]
- POSTGRES_DB=[some db]
image: postgres:11.4-alpine
container_name: db
restart: always
networks:
- hasura-db
networks:
hasura-db:
There is a Pull request in the hasura graphql project for this issue, but is not merged.
I'm looking for a workaround for this pull request now.
I found a workaround for this!
If I install hasura cli in my machine and use
hasura console --console-port 8080 --endpoint http://127.0.0.1:8081
I can connect to the hasura api and run a console locally.
this is my updated docker-compose.yml
version: '3'
services:
hasura:
environment:
- HASURA_GRAPHQL_DATABASE_URL=postgres://[some pass]:[some user]#db:5432/[some db]
- HASURA_GRAPHQL_ENABLE_CONSOLE=false
image: hasura/graphql-engine:v1.0.0-rc.1.cli-migrations
container_name: hasura
volumes:
- ./hasura-migrations:/hasura-migrations
networks:
- hasura-db
ports:
- "8081:8080"
restart: always
db:
environment:
- POSTGRES_USER=[some user]
- POSTGRES_PASSWORD=[some pass]
- POSTGRES_DB=[some db]
image: postgres:11.4-alpine
container_name: db
restart: always
networks:
- hasura-db
networks:
hasura-db: