Host network mode for cps-service has been re-enabled with https://gerrit.onap.org/r/c/cps/+/115022
I was not able to find details about the issue we are fixing with this change. Can someone please share ?
On my side, when running docker compose, I'm not able to connect to cps-service in host network mode as the service port is not exposed.
➜ ~ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 40a1239d6942 nexus3.onap.org:10001/onap/cps-service:0.0.1-SNAPSHOT "java -cp /app/resou…" 37 seconds ago Up 36 seconds cps-service e79c9adeeb76 postgres "docker-entrypoint.s…" 37 seconds ago Up 36 seconds 0.0.0.0:5432->5432/tcp dbpostgresql
Connection to port 8080 is not available:
➜ ~ telnet localhost 8080
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
Trying ::1...
telnet: connect to address ::1: Connection refused
telnet: Unable to connect to remote host
➜ ~ curl -I http://localhost:8080/api/cps/swagger-ui/index.html
curl: (7) Failed to connect to localhost port 8080: Connection refused
To remediate this, locally, here is how I'm running docker compose without cps-service in host network mode:
cps-service is accessing the database using `dbpostgresql` hostname:
VERSION=0.0.1-SNAPSHOT DB_HOST=dbpostgresql DB_USERNAME=cps DB_PASSWORD=cps docker-compose up
From localhost, all services ports are exposed:
➜ ~ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 44e65d918cb4 nexus3.onap.org:10001/onap/cps-service:0.0.1-SNAPSHOT "java -cp /app/resou…" 2 minutes ago Up 2 minutes 0.0.0.0:8080->8080/tcp cps-service 65a65cff8a89 postgres "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:5432->5432/tcp dbpostgresql
And also available for connection:
➜ ~ telnet localhost 5432 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. ^] telnet> q Connection closed. ➜ ~ telnet localhost 8080 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. ^] telnet> q Connection closed. ➜ ~ curl -I http://localhost:8080/api/cps/swagger-ui/index.html HTTP/1.1 200 OK Date: Thu, 19 Nov 2020 18:00:49 GMT Vary: Origin Vary: Access-Control-Request-Method Vary: Access-Control-Request-Headers Last-Modified: Thu, 01 Jan 1970 00:00:01 GMT Content-Type: text/html Accept-Ranges: bytes Content-Length: 3129
See also https://docs.docker.com/network/host/
What do you think ? Do you have the same issue on your side ?