jboss 无法从主机访问Wildfly容器

xqkwcwgp  于 2022-11-08  发布在  其他
关注(0)|答案(1)|浏览(210)

我需要访问部署到容器中的wildfly的应用程序,但是我无法访问。我非常确定该应用程序正在容器中的端口8443上运行。为了构建映像,我使用了以下命令,注意端口转发参数。

docker run -p 8443:8443 folio-authentication-local:latest

要运行映像,我使用以下命令:

docker run -p 8443:8443 folio-authentication-local:latest

当容器启动时没有错误。而且,我可以打开一个外壳到容器中,并点击端点,我看到返回的内容(见下面的屏幕截图)。
然而,从主机浏览器,我得到一个错误,该页无法找到(见第二个屏幕截图)。
希望有人能让我知道我错过了什么。
停靠文件:


### BUILD image

FROM maven:3.5-jdk-8-alpine as builder
ARG BRANCH_NAME=local
ARG mongo_replicaset=localhost:27017,localhost:27017,localhost:27017

EXPOSE 8443

# Create app folder for sources

RUN mkdir -p /build
WORKDIR /build
COPY pom.xml /build

# Download all required dependencies into one layer

RUN mvn -B dependency:resolve dependency:resolve-plugins

# Copy source code

COPY src /build/src

# Build application

RUN mvn package

WORKDIR /

# Copy all configurations into the image from the host

RUN mkdir -p /WildflyConfiguration
COPY  /WildflyConfiguration/* /WildflyConfiguration

# Copy all scripts into the image from the host

RUN mkdir -p /SetStandaloneXmlSettingsScripts
COPY  /SetStandaloneXmlSettingsScripts/* /SetStandaloneXmlSettingsScripts

# Set permissions on the folder

RUN chmod -R 777 ./SetStandaloneXmlSettingsScripts

# Update the standalone.xml file

RUN if [ "${BRANCH_NAME}" = "development" ]; then \ 
    ./SetStandaloneXmlSettingsScripts/setEKSDevStandaloneXmlSettings.sh; \
elif [ "${BRANCH_NAME}" = "local" ]; then \
    ./SetStandaloneXmlSettingsScripts/setLocalStandaloneXmlSettings.sh; \       
else \
    echo "There was no branch name found that matches your standalon" && exit 1; \
fi 

# Create the deployment

FROM jboss/wildfly:21.0.2.Final as Final

# Copy the artifact to the deployments folder

COPY --from=builder /build/target/Authentication.war /opt/jboss/wildfly/standalone/deployments/Authentication.war

# Copy the standalone configuration into wildfly

COPY --from=builder /WildflyConfiguration/standalone.xml /opt/jboss/wildfly/standalone/configuration/standalone.xml

ENTRYPOINT ["/opt/jboss/wildfly/bin/standalone.sh"]

pgky5nke

pgky5nke1#

默认情况下,WildFly被配置为绑定到环回地址(127.0.0.1),因此您无法从容器外部访问服务器。您可以通过将-b参数传递给standalone.sh来覆盖此设置。
例如,要绑定到所有可用的接口,可以将ENTRYPOINT修改为以下内容。

ENTRYPOINT ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]

相关问题