Docker / Dockerfile:使用ENTRYPOINT进行git clone

我试图在我的Dockerfile中运行一个git clone命令作为入口点,这样它就不会被caching,我保证会拥有最新的源代码。 目前我在Dockerfile中有以下代码:

FROM ubuntu:trusty MAINTAINER Fernando Mayo <fernando@tutum.co>, Feng Honglin <hfeng@tutum.co> # Install packages ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && \ apt-get -y install vim supervisor git curl unzip apache2 libapache2-mod-php5 pwgen php-apc php5-mcrypt php5-mysql php5-curl&& \ echo "ServerName localhost" >> /etc/apache2/apache2.conf # Install Composer RUN curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer RUN composer global require "laravel/installer" ENV PATH ~/.composer/vendor/bin:$PATH # Add image configuration and scripts ADD start-apache2.sh /start-apache2.sh ADD start-mysqld.sh /start-mysqld.sh ADD run.sh /run.sh RUN chmod 755 /*.sh ADD my.cnf /etc/mysql/conf.d/my.cnf ADD supervisord-apache2.conf /etc/supervisor/conf.d/supervisord-apache2.conf ADD supervisord-mysqld.conf /etc/supervisor/conf.d/supervisord-mysqld.conf ADD php.ini /etc/php5/cli/php.ini ADD 000-default.conf /etc/apache2/sites-available/000-default.conf # config to enable .htaccess RUN a2enmod rewrite # Copy over private key, and set permissions ADD .ssh /root/.ssh # Get aws stuff RUN curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" RUN unzip awscli-bundle.zip RUN ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws # Clone the repo RUN rm -rd /var/www/html RUN git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Laravel /var/www/html # Set file permissions RUN chmod -R 777 /var/www/html/storage RUN chmod -R 777 /var/www/html/bootstrap/cache # Environment variables to configure php ENV PHP_UPLOAD_MAX_FILESIZE 10M ENV PHP_POST_MAX_SIZE 10M EXPOSE 80 3306 CMD ["/run.sh"] 

要删除caching,我更改了以下几行:

 # Clone the repo RUN rm -rd /var/www/html RUN git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Laravel /var/www/html # Set file permissions RUN chmod -R 777 /var/www/html/storage RUN chmod -R 777 /var/www/html/bootstrap/cache 

 # Clone the repo RUN rm -rd /var/www/html ENTRYPOINT git clone ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/Laravel /var/www/html # Set file permissions ENTRYPOINT chmod -R 777 /var/www/html/storage ENTRYPOINT chmod -R 777 /var/www/html/bootstrap/cache 

我可以build立这个Dockerfile,但是当我运行它停止之前,我可以做任何事情(我无法访问它与本地主机,我没有看到任何错误)。 我在做什么错误入口?

你的切入点只是做一件事而退出。 你可能想要在你的入口点运行你的服务器,这样容器就可以存在了。 在你的情况,似乎你想运行run.sh

另外,只允许一个ENTRYPOINT点。 您应该将多个入口点转换为脚本并将其用作入口点。 从文档 :

只有ENTRYPOINT中的最后一条ENTRYPOINT指令才会起作用。