Dockerfile JBOSS无法访问本地

时间:2018-07-24 02:21:05

标签: docker

我正在创建一个运行JBOSS EAP 7的Dockerfile,请参阅我的dockerfile:

FROM mlaccetti/docker-debian-java8
# file author / maintainer
MAINTAINER "Ronaldo Lanhellas" "ronaldo.lanhellas@gmail.com"

USER root
RUN apt-get update;apt-get install sudo -y

RUN adduser --disabled-password --gecos '' docker
RUN adduser docker sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER docker
RUN sudo mkdir -p /opt/jboss/jboss-eap-7.0
COPY jboss-eap-7.0 /opt/jboss/jboss-eap-7.0
ENV JBOSS_HOME /opt/jboss/jboss-eap-7.0
RUN sudo chown -R docker:docker /opt/jboss/*;sudo chmod +x /opt/jboss/jboss-eap-7.0/bin/standalone.sh
RUN java -version
#RUN sudo apt-get install default-jdk -y
CMD sudo sh $JBOSS_HOME/bin/standalone.sh

EXPOSE 8080 9990

jboss-eap-7正常启动,server.log中没有错误。但是尝试从主机访问地址-> http://localhost:8080我无法访问。

编辑1 在docker容器中查看,这是我的IP:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
44: eth0@if45: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
       valid_lft forever preferred_lft forever

但是我的网络(主机)是:192.168.0.x。为什么docker不使用与主机相同的IP或同一网络中的另一个IP?我认为这可能是造成问题的原因。

1 个答案:

答案 0 :(得分:1)

您需要发布容器的端口,如下所示: docker run -p 8080:8080 mlaccetti/docker-debian-java8