In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Before we begin
Why do I need to customize a PHP base image?
For projects developed using php (python), because it is an interpreted language, you do not need to compile the code this step (go or java packages the dependencies into executable programs or packages), but you often need to install some dependent libraries or third-party modules.
In project practice, some necessary extension modules are added on top of the official PHP image, such as mysqlnd module connecting to mysql database, or commonly used php expansion modules such as redis, memcache, mongodb, etc., depending on the actual requirements of the project.
The basic image is used to provide support for the project image. After the php basic image is prepared, the basic image is used as the basis and project code is added to complete the construction of the project image. Except for major security updates and adding new extension modules, the basic image is not updated and adjusted frequently.
Take a chestnut.
An example is used to describe the basic php image. The environment and requirements are as follows:
The project is based on `php5 + mysql` development. The project uses `project fpm` to run the project code. The project uses `nginx` reverse proxy php-fpm and provides' static resource 'service. The project requires php extension modules such as `mysqlnd, redis, memcache`, etc.
By default, docker runs only one process (the idea advocated by docker), but the project requires two services (php-fpm and nginx), so it requires third-party process management software. The more popular solution in docker is to use supervisor software to manage multiple processes.
This article focuses on how to implement a php basic image, and the next article will show you how to use supervisor to manage multiple processes.
Based on the above requirements, the Dockerfile file is designed. Cat base/php/5.6/Dockerfile# uses php:5.6-fpm official image FROM php:5.6-fpmMAINTAINER dongnan # # envENV TZ= "Asia/Shanghai"\ LANG= "en_US.UTF-8" # aptCOPY conf/sources.list / etc/apt/sources.listRUN apt-get update & & apt-get install-y\ supervisor nginx\ libfreetype6-dev\ libjpeg62-turbo-dev\ libmcrypt-dev\ libpng-dev\ libmagickwand- Dev\ libmemcached-dev\ bzip2\ & & apt-get clean & & rm-r / var/lib/apt/lists/*# extRUN docker-php-ext-install bcmath\ dba\ exif\ mysqli\ pdo_mysql\ sysvsem\ sysvshm\ bz2\ zip\ mysql# gdRUN docker-php-ext-install-j$ iconv mcrypt\ & & docker-php-ext-configure gd\-- with-freetype -dir=/usr/include/\-with-jpeg-dir=/usr/include/\ & & docker-php-ext-install-j$ (nproc) gd # peclRUN pecl install imagick\ memcached-2.2.0\ redis-4.3.0\ & & docker-php-ext-enable imagick\ & & docker-php-ext-enable memcached\ & & docker-php-ext-enable redis to build an image cd base/php/5.6/ Docker build-t demo-base:0.0.1 .Sending build context to Docker daemon 3.0 kb# omitted.... Successfully built cd34135ed904
Do not understand the meaning of Dockerfile file parameters, or how to use the build command, please refer to this article "how to use Dockerfile custom images?" "
Verify the image docker images-- format'{{.Repository}} {{.size}} 'demo-base 723MB
You can use this php basic image to create a container, but this container (image) has already installed nginx but will not run. Currently, only the default php-fpm is running. This problem will be solved in the next article, "using supervisor to manage multiple processes in Docker containers." Please wait for the official account to update the docker feature every Thursday.
Summary
Finally, let's summarize the knowledge points in the article.
The role of the basic image is to provide support for the project image, and add the project code to the basic image to complete the construction of the project image. With the exception of major security updates and the addition of new expansion modules, the underlying image is not updated frequently. By default, docker runs only one process, which requires supervisor process management software to manage multiple processes.
Reference article
Doker&k8s Qun [703906133]
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.