I am having trouble exposing a port from a docker container to my server. Here is what I've done:
I wrote a very simple spring boot app that runs on port 8080.
Now I am trying to deploy it into a docker container on my server.
Based on the Spring - Getting started with Docker Userguide I've created the following Dockerfile:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
In a second step I copied my jar to the same directory (where the dockerfile is stored) and built the container with the following command:
docker build . -t testportmapping --build-arg JAR_FILE=swagger-v2-person-ws-0.0.1-SNAPSHOT.jar
Now when I run:
docker run -d testportmapping:latest -p 9065:8080
The command runs without an error. But if I take a look at: docker container ls: I see that no portmapping was created:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f15639c81903 testportmapping:latest "java -Djava.securit…" About 6 minutes ago Up 6 minutes mystifying_payne
Does anyone know that I am doing wrong?
What I've tried so far:
- Using different local port
- Adding an EXPOSE to the Dockerfile
- Addinng
--net=hostto thedocker runcommand - Running the container attached to see if the app starts up correctly (it does)
My setup:
root@jupiter /h/n/d/p/swagger-v2# docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:24:56 2018
OS/Arch: linux/amd64
Experimental: false
Server:
Engine:
Version: 18.06.1-ce
API version: 1.38 (minimum version 1.12)
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:21 2018
OS/Arch: linux/amd64
Experimental: false
root@jupiter /h/n/d/p/swagger-v2# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial