По какой-то причине netstat
не отображает порты, отображаемые Docker. Как предложено здесь Я использовал EXPOSE
для обоих портов 8080 и 5050. Но ни один из них не виден с хоста.
Dockerfile
...
FROM openjdk:11-jre-slim
COPY --from=build /usr/src/app/api/target/track-metadata-api-*.jar /app/track-metadata-api.jar
WORKDIR /app
EXPOSE 8080 5050
CMD java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5050 -jar track-metadata-api.jar
Docker PS
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a6d3381a992d track-metadata_track-metadata "/bin/sh -c 'java -a…" 7 minutes ago Up 7 minutes 0.0.0.0:5050->5050/tcp, 0.0.0.0:8080->8080/tcp track-metadata_track-metadata_1
netstat & curl
$ sudo netstat --all | grep 8080 # returns nothing
$ curl http://localhost:8080/v1/track-metadata/filtered
[{"authorName":"AC/DC","duration":208,"id":1,"tags":"#rock","trackName":"Highway to Hell"},{"authorName":"Sum41","duration":209,"id":2,"tags":"#rock","trackName":"War"},{"authorName":"Ziggy Marley","duration":220,"id":3,"tags":"#ragge","trackName":"Beach in Hawaii"}]
Версия Docker & Ubuntu
$ docker --version
Docker version 18.06.1-ce, build e68fc7a
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.10
Release: 18.10
Кодовое имя: космическое