Docker Beginner's introduction to the six: Docker in the production environment of the use of practice

Source: Internet
Author: User
Tags mkdir

Reproduced in the process, the picture is missing, the code shows confusion.

For better learning content, please visit the original version:

https://www.missshi.cn/api/view/blog/5a6328110a745f6335000006

Ps: Initial access due to the large JS file, please wait patiently (5s or so)


in the previous article, we briefly introduced some simple practices of the Docker. Next, we'll talk about similar content in this article, but the services deployed with Docker will be more complex than that. Build a Jekyll framework website

The first application we'll build in this article is a custom Web site that uses the Jekyll framework.
The site will include the following two mirrors: a mirrored installation of Jekyll and its associated software package a mirror installation of the Apache service is used to make the site work properly.

Then the development process can be translated as follows: Create Jekyll base mirrors and Apache mirrors create a container with a Jekyll mirror and mount the source code for the site through the volume. Use the Apache image to create a container that leverages and serves the volume that contains the compiled Web site. When the Web site is updated, jump to step 2 to repeat execution. Jekyll Base Mirroring

First, we need to create the first Jekyll base mirror.
We need to create a new directory and create the Dockerfile files needed for the mirror.

mkdir Jekyll CD Jekyll Touch Dockerfile

Modify the Dockerfile file as follows:

From ubuntu:16.04 maintainer Nianshi <nianshi0912@gmail.com> ENV refreshed_at 2018-02-17 run APT-GET-QQ update run APT-GET-QQ install ruby Ruby-dev build-essential nodejs libffi-dev RUN gem install--no-rdoc--no-ri Jekyll Volume/data volume/var/www/html workdir/data entrypoint ["Jekyll", "Build", "--destination=/var/www/html"]

In the Dockerfile file, we first installed Ruby and related packages, in addition, we created two volumes using the volume Directive:/data/to store the source code for the site,/var/www/html to store the compiled Jekyll files. Building Jekyll Base mirroring

After creating the Dockerfile file, we can execute the following command to build the Mirror:

Docker build-t Nianshi/jekyll.

After the command execution is complete, we create a Jekyll base mirror. Apache Base Mirroring

Next, we need to continue to create a new folder to build the Apache image.

mkdir Apache CD Apache Touch dockerfile

Modify the Dockerfile file as follows:

From ubuntu:16.04 maintainer Nianshi <nianshi0912@gmail.com> run APT-GET-QQ update RUN apt-get-qq 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-entrypoint ["/usr/sbin/apache2" ] CMD ["D", "foreground"] Building Apache Mirrors

After creating the Dockerfile file, we can execute the following command to build the Mirror:

Docker build-t Nianshi/apache.

When the command completes, we create a base image of Apache.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.