我在docker上部署了我的第一个scala项目,但是我有一个问题,问题是docker说服务器已经启动了,但令人惊讶的是它不会监听任何请求,即使我将端口暴露给主机,当我试图请求获取时,它说连接被拒绝,我也尝试telnet到端口,似乎端口9000上没有监听器3200和3000,请找到我在dockerFile中写的内容< / p>
FROM jelastic/sbt
# Env variables
ENV SCALA_VERSION 2.12.4
ENV SBT_VERSION 1.1.0
# Scala expects this file
RUN touch /usr/lib/jvm/java-8-openjdk-amd64/release
# Install Scala
## Piping curl directly in tar
RUN \
curl -fsL https://downloads.typesafe.com/scala/$SCALA_VERSION/scala-$SCALA_VERSION.tgz | tar xfz - -C /root/ && \
echo >> /root/.bashrc && \
echo "export PATH=~/scala-$SCALA_VERSION/bin:$PATH" >> /root/.bashrc
# Install sbt
RUN \
curl -L -o sbt-$SBT_VERSION.deb https://dl.bintray.com/sbt/debian/sbt-$SBT_VERSION.deb && \
dpkg -i sbt-$SBT_VERSION.deb && \
rm sbt-$SBT_VERSION.deb && \
apt-get update && \
apt-get install sbt && \
sbt sbtVersion
WORKDIR /
ADD play /
RUN tree /
EXPOSE 9000
CMD sbt run
我的运行命令是
docker run -p 9000:9000 -t bee while bee is my image name
如您所见,服务器已正常启动。