Dockerfile builds a personalized image based on the previous image, and the CMD specified in the dockerfile of the original image is not executed.

1. The original dockerfile, builds an image with jdk installed based on centos:7
FROM centos:7

MAINTAINER wenyoulong < 3424675994@qq.com >

ENV JAVA_HOME / usr/local/java/jdk1.8.0_181
ENV JRE_HOME ${JAVA_HOME} / jre
ENV CLASSPATH.: ${JAVA_HOME} / lib:$ {JRE_HOME} / lib
ENV PATH ${JAVA_HOME} / bin:$PATH

COPY jdk-8u181-linux-x64.tar.gz / java/jdk-8u181-linux-x64.tar.gz
COPY setup.sh / java/setup.sh

CMD ["sh", "/ java/setup.sh"]

2. Build a new image with tomcat installed based on the image you just built
FROM my-java:latest

MAINTAINER wenyoulong < 3424675994@qq.com >

COPY apache-tomcat-8.5.33.tar.gz / tomcat/apache-tomcat-8.5.33.tar.gz
COPY setup.sh / tomcat/setup.sh

CMD ["sh", "/ tomcat/setup.sh"]

3. Run tomcat after the completion of the construction and discover that the CMD specified by the mirror did not execute

Jun.14,2021

this is right. CMD is a script executed by docker run , and it is a running configuration, so after you FROM, you will naturally be overwritten by your new CMD configuration


CMD only one. You should use RUN .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e460f4-44b85.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e460f4-44b85.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?