There is a problem with docker: the dockerfile cannot be started (/bin/bash is added after the start command to cause it to fail to start) solution

Docker use tutorial related series catalog


problem:

Write a dockerfile, then build a mirror through the dockerfile, the built mirror generates a container, and then starts

FROM centos:7
MAINTAINER www.zenghw.com
ENV VERSION=8.5.47
RUN yum install java-1.8.0-openjdk wget curl unzip iproute net-tools -y && \
    yum clean all && \
    rm -rf /var/cache/yum/*
COPY apache-tomcat-8.5.47.zip /tmp
RUN cd /tmp && \
    unzip apache-tomcat-8.5.47.zip  && \
    mv apache-tomcat-8.5.47 /usr/local/tomcat8 && \
    rm -rf apache-tomcat-8.5.47.zip  && \
    cd /usr/local/tomcat8/bin/ && \
    chmod +x *.sh && \
    sed -i '1a JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"' /usr/local/tomcat8/bin/catalina.sh && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
ENV PATH $PATH:/usr/local/tomcat8/bin
WORKDIR /usr/local/tomcat8
EXPOSE 8080
CMD ["/usr/local/tomcat8/bin/catalina.sh", "run"]

docker build -t tomcat:v1 -f Dockerfile-tomcat . 
docker run -d -i -t --name=tomcatv1 -p 8888:8080 tomcat:v1 /bin/bash

Analyze the reasons

The function of /bin/bash is to run bash after loading the container. A process must be kept running in the docker, otherwise the entire container will be killed immediately after it is started.

The command has been declared in the dockerfile

CMD ["/usr/local/tomcat8/bin/catalina.sh", "run"]

solution

When the container starts, do not add /bin/bash after the run command

Guess you like

Origin blog.csdn.net/shi_hong_fei_hei/article/details/114646659