我拥有这一简便的 JavaSOAP服务,在当地机器中进行罚款。
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class EchoService {
@WebMethod
public String echo(@WebParam(name = "message") String message) {
return message;
}
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/echoservice", new EchoService());
System.out.println("Service published at http://localhost:8080/echoservice");
}
}
当我开始在当地工作时,我可以通过http:// localhost:8080/echoservice来提供服务。
然后,我试图使用cker器并部署集装箱式版本。 这是我的Dockerfile
FROM maven:3.8.4-openjdk-11 AS build
WORKDIR /app
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src ./src
RUN mvn package
FROM openjdk:11-jre-slim
WORKDIR /app
COPY --from=build /app/target/*.jar ./app.jar
COPY --from=build /app/target/libs ./libs
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]
这些是我的cker。
docker build -t java-soap:1.0 .
docker run -p 8080:8080 java-soap:1.0
After starting the container, I can see the server is running but it is no longer reachable via http://localhost:8080/echoservice.
What should be the issue here? Is this related to Docker network interfaces? Is there a way to fix this?