構(gòu)建jekyll
注意:不要使用ubuntu的apt-get命令安裝ruby,版本較舊,安裝不了jekyll
mkdir ~/jekyll && cd ~/jekyll && vim Dockerfile
FROM ubuntu:14.04
MAINTAINER Lyndon
WORKDIR /tmp
RUN apt-get -yqq update
RUN apt-get -yqq install wget make nodejs
RUN wget -O ruby-install-0.6.1.tar.gz https://github.com/postmodern/ruby-install/archive/v0.6.1.tar.gz
RUN tar -xzvf ruby-install-0.6.1.tar.gz
WORKDIR /tmp/ruby-install-0.6.1
RUN make install
RUN ruby-install --latest --system ruby
RUN gem install --no-rdoc --no-ri jekyll
VOLUME /data
VOLUME /var/www/html
WORKDIR /data
ENTRYPOINT [ "jekyll", "build", "--destination=/var/www/html" ]
docker build -t lyndon/jekyll .
構(gòu)建Apache
mkdir ~/apache && cd ~/apache && vim Dockerfile
FROM ubuntu:14.04
MAINTAINER Lyndon
RUN apt-get -yqq update
RUN apt-get -yqq install apache2
VOLUME [ "/var/www/html" ]
WORKDIR /var/www/html
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
RUN mkdir -p $APACHE_RUN_DIR $APACHE_LOCK_DIR $APACHE_LOG_DIR
EXPOSE 80
ENTRYPOINT [ "/usr/sbin/apache2" ]
CMD ["-D", "FOREGROUND"]
docker build -t lyndon/apache .
啟動(dòng)jekyll網(wǎng)站
cd ~
git clone https://github.com/jamtur01/james_blog.git
docker run -v ~/james_blog:/data/ --name james_blog lyndon/jekyll
#自動(dòng)編譯: docker run -v ~/james_blog:/data/ --name james_blog lyndon/jekyll jekyll build --destination=/var/www/html --incremental --watch
docker run -d -P --volumes-from james_blog lyndon/apache