Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker/Dockerfile:使用ENTRYPOINT进行git克隆_Docker_Dockerfile - Fatal编程技术网

Docker/Dockerfile:使用ENTRYPOINT进行git克隆

Docker/Dockerfile:使用ENTRYPOINT进行git克隆,docker,dockerfile,Docker,Dockerfile,我试图在Dockerfile中运行一个git clone命令作为入口点,这样它就不会被缓存,而且我保证拥有最新的源代码。目前我在Dockerfile中有以下代码: FROM ubuntu:trusty MAINTAINER Fernando Mayo <fernando@tutum.co>, Feng Honglin <hfeng@tutum.co> # Install packages ENV DEBIAN_FRONTEND noninteractive RUN ap

我试图在Dockerfile中运行一个git clone命令作为入口点,这样它就不会被缓存,而且我保证拥有最新的源代码。目前我在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"]


我可以构建这个Dockerfile,但当我运行它时,它会在我可以做任何事情之前停止(我无法使用localhost访问它,并且我没有看到任何错误)。入口点有什么不对吗?

您的入口点只做一件事,然后退出。您可能希望在入口点中运行服务器,以便容器保持不变。在您的情况下,似乎要运行
run.sh

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

只有Dockerfile中的最后一条
入口点
指令将具有 效果

# 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