我有一个用perl编写的工具,它可以将具有特定修订版的Java应用程序部署到远程服务器,如tomcat或wildfly/JBoss。
因此,该工具需要连接到wildfly,然后连接到使用ssh运行wildfly的maschine。
我想要将整个过程停靠起来。因此,我的部署工具应该在容器中运行,并且远程服务器也应该被dockerized化。
有没有一种方法可以在一个容器中运行wildfly和ssh,这样它就可以描述一个服务器?
我尝试使用以下Dockerfile对接服务器,但没有成功
## SELECT IMAGE
FROM ubuntu:18.04
RUN apt-get update && \
apt-get upgrade -y && \
apt install -y openjdk-11-jdk && \
apt install -y subversion && \
apt install -y openssh-server && \
apt install -y wget
RUN mkdir /var/run/sshd
RUN sed -i 's/#*PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
RUN sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
ENV NOTVISIBLE="in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
RUN useradd -ms /bin/bash user
RUN usermod -aG sudo user
## SET JAVA ENV
ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64
## COPY CONF FILES TO ROOT
COPY conf/root/ssh/ /root/.ssh/
COPY conf/root/subversion/auth /root/.subversion/auth
## INSTALL JBOSS
RUN wget -O /tmp/wildfly-16.0.0.Final.tar.gz \
https://download.jboss.org/wildfly/16.0.0.Final/wildfly-16.0.0.Final.tar.gz && \
tar zxvf /tmp/wildfly-16.0.0.Final.tar.gz -C /opt
## JBOSS CONFIG
RUN sed -i -r 's/jboss.bind.address.management:127.0.0.1/jboss.bind.address.management:0.0.0.0/' \
/opt/wildfly-16.0.0.Final/standalone/configuration/standalone.xml
## CLEAN JBOSS
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
USER root
EXPOSE 8080 9990
EXPOSE 22
CMD /usr/sbin/sshd
RUN /opt/wildfly-16.0.0.Final/bin/add-user.sh --silent=true admin admin
CMD /opt/wildfly-16.0.0.Final/bin/standalone.sh -b=0.0.0.0wildfly服务器正在运行,我可以访问它。这是完美的工作。但是ssh不起作用。
发布于 2020-09-30 22:41:14
Docker旨在用于创建应用程序容器--即包含单个服务的容器。正因为如此,在构建映像时只考虑了最后一个CMD。如果您执行docker inspect image_name,您将看到您的映像的命令设置为/opt/wildfly-16.0.0.Final/bin/standalone.sh -b=0.0.0.0。
可以(但不建议)通过添加启动、停止和监视其他服务的监控服务来绕过此限制。official documentation中列出了此方法的详细信息。
https://stackoverflow.com/questions/64139359
复制相似问题