English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Docker is built on the basis of the Linux kernel. At present, the mainstream Linux systems all have native support for Docker and the best user experience. Of course, Docker is also supported on Windows and MacOS platforms, but it needs to use similar Boot2Docker and other virtualization tools provide Linux support.
Below, we focus on introducing the differences between the two methods of creating docker images when starting containers. Those who are interested can learn with the editor!
1.Any image generated by docker commit can load a script to start its own application when it is started, for example:
docker run -d -P tomcat7.0b:jdk1.6 /run.sh
The final/run.sh is used to start the tomcat application, indicating that when the container is started, the tomcat application is also started. Otherwise, only the container is started, and the application itself is not started.
The content of run.sh is as follows:
#!/bin/bash /usr/sbin/sshd -D & exec ${CATALINA_HOME}/bin/catalina.sh run
And note that, at present, this container is an instance of the image instantiated based on the Docfile file. If you perform an operation and then use docker commit to generate a new image based on this container, then the container generated based on the new image still needs to load a script to start its own application.
2When starting the container with the image generated by the Docfile file, you don't need to add this script anymore.
FROM sshd3:ubuntu MAINTAINER waitfish from dockerpool.com([email protected]) ENV DEBIAN_FRONTEND noninteractive RUN echo "Asia/Shanghai" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata RUN apt-get install -yq --no-install-recommends wget pwgen ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists/* ENV CATALINA_HOME /tomcat ENV JAVA_HOME /jdk ADD apache-tomcat-7.0.69 /tomcat ADD jdk1.6.0_45 /jdk #ADD create_tomcat_admin_user.sh /create_tomcat_admin_user.sh ADD run.sh /run.sh RUN chmod +x /*.sh RUN chmod +x /tomcat/bin/*.sh EXPOSE 8080 CMD ["/run.sh"]
Because the last sentence CMD is used to indicate that this script is called when the container starts.
The above is a summary of the two types of container startup image creation introduced by the editor, hoping it will be helpful to everyone. If you have any questions, please leave a message, and the editor will reply to everyone in time. Here, I also want to express my sincere gratitude to everyone for their support of the Yanaolang tutorial website!