本文转自:https://docs.docker.com/samples/library/php/

How to use this image

Create a Dockerfile in your PHP project

FROM php:7.2-cli
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
CMD [ "php", "./your-script.php" ]

Then, run the commands to build and run the Docker image:

$ docker build -t my-php-app .
$ docker run -it --rm --name my-running-app my-php-app

How to install more PHP extensions

Many extensions are already compiled into the image, so it’s worth checking the output of php -m or php -i before going through the effort of compiling more.

We provide the helper scripts docker-php-ext-configuredocker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.

In order to keep the images smaller, PHP’s source is kept in a compressed tar file. To facilitate linking of PHP’s source with any extension, we also provide the helper script docker-php-source to easily extract the tar or delete the extracted source. Note: if you do use docker-php-source to extract the source, be sure to delete it in the same layer of the docker image.

FROM php:7.2-cli
RUN docker-php-source extract \
# do important things \
&& docker-php-source delete

PHP Core Extensions

For example, if you want to have a PHP-FPM image with iconv and gd extensions, you can inherit the base image that you like, and write your own Dockerfile like this:

FROM php:7.2-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

Remember, you must install dependencies for your extensions manually. If an extension needs custom configure arguments, you can use the docker-php-ext-configure script like this example. There is no need to run docker-php-source manually in this case, since that is handled by the configure and install scripts.

See “Dockerizing Compiled Software” for a description of the technique Tianon uses for determining the necessary build-time dependencies for any bit of software (which applies directly to compiling PHP extensions).

[转]Docker php extensions gd的更多相关文章

  1. Docker运行sonarqube-(代码质量检测平台)

    sonarqube是什么 SonarQube是用于持续检查代码质量的开源平台. 可用于持续集成,持续部署流程中的代码检测环节. idea和jenkins都提供了插件配合使用. liunx推荐配置环境 ...

  2. Helpers\RainCaptcha

    Helpers\RainCaptcha This class can validate CAPTCHA images with RainCaptcha. It can generate an URL ...

  3. 安装Zabbix5.0

    目录 概述 支持的平台 安全相关 支持TimescaleDB agent升级 垂直菜单 部署 安装要求 数据库要求 前端要求 服务端要求 Agent 2 Java gateway 安装 配置镜像源 安 ...

  4. Jenkins+Sonar 项目构建前代码审查

    一.sonar简介 1.概述 Sonar (SonarQube)是一个开源平台,用于持续检查代码质量,不只是一个质量数据报告工具,更是代码质量管理平台. 支持Java, C#, C/C++, PL/S ...

  5. 部署Zabbix 6.0 LTS

    Blog:博客园 个人 本部署文档适用于CentOS 8.X/RHEL 8.X/Anolis OS 8.X/AlmaLinux 8.X. Zabbix 6.0 LTS于2022年2月15日发布,本次大 ...

  6. 给docker里的php安装gd扩展

    docker官方镜像为安装php扩展封装了函数,为开发者提供了很大的便利,以下以Dockerfile的形式演示安装gd扩展的方法,安装gd扩展需要安装几个依赖包,安装依赖包使用系统命令,安装命令根据基 ...

  7. docker安装GD扩展

    apt update #更新软件源 apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev #安装各种库 docker-p ...

  8. Docker为PHP安装gd扩展

    安装扩展库的通常命令 docker-php-ext-install 扩展库名 安装gd库需要特殊照顾,步骤如下 //进入PHP容器 //更新软件源 apt update //安装各种库 apt ins ...

  9. Docker的镜像

    镜像是容器的运行基础,容器是镜像运行后台的形态 镜像的概念 镜像是一个包含程序运行必要依赖环境和代码的只读文件,它采用分层的文件系统,将每一次改变以读写层的形式增加到原来的只读文件上 镜像的系统结构 ...

随机推荐

  1. 剑指offer面试题25:二叉树中和为某一值的路径

    题目:输入一棵二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径.从根节点开始往下一直到叶节点所经过的节点形成一条路径. 解题思路:当使用前序遍历的方式访问某一节点时,把该节点添加到路径上 ...

  2. {黑掉这个盒子} \\ FluxCapacitor Write-Up

    源标题:{Hack the Box} \ FluxCapacitor Write-Up 标签(空格分隔): CTF   好孩子们.今天我们将学习耐心和情绪管理的优点.并且也许有一些关于绕过WEB应用防 ...

  3. 《http权威指南》读书笔记14

    概述 最近对http很感兴趣,于是开始看<http权威指南>.别人都说这本书有点老了,而且内容太多.我个人觉得这本书写的太好了,非常长知识,让你知道关于http的很多概念,不仅告诉你怎么做 ...

  4. lazy-init 懒加载的艺术

    懒加载是一种加载方式,加载单例对象一般有两种方式,一是在启动时就立即创建好,另一种则是在需要用到的时候再去加载即懒加载.懒加载一般会针对单例场景,且一般是针对在加载消耗较大费时,且不一定会用到的场景. ...

  5. GitLab CI .NET 部署中的几个坑

    信息乱码 Msbuild编译失败 VS却编译成功 设置环境变量本地有用,但是runner跑起来就失败 powershell公共变量为空 命令执行失败,却集成成功,pass了 1.信息乱码 信息乱码是真 ...

  6. 【spring】task 任务调度(定时任务)

    1.定时任务的几种实现可以看这里:http://gong1208.iteye.com/blog/1773177 2.需要导入spring的jar包,可以参看之前的[spring]相关文章 3.这里使用 ...

  7. RabbitMQ配置

    RabbitMQ Configuration RabbitMQ提供多种配置方式:配置文件.环境变量.运行时参数等等. 默认配置文件的位置在/etc/rabbitmq/ Config File Loca ...

  8. java中fail-fast 和 fail-safe的区别

    java中fail-fast 和 fail-safe的区别   原文地址:http://javahungry.blogspot.com/2014/04/fail-fast-iterator-vs-fa ...

  9. [android]__如何在studio中导入,使用开源的UI组件

    前言 在编程开发中,我们对第三方的优质开源组件是十分依赖的,在很多时候,我们都会使用到他们.使用第三方开源组件能够给我们的编程开发带来很大的便利.今天以这篇文章记录关于在android项目中引用第三方 ...

  10. Google的java工具类Guava

    前言 google开发java项目肯定也不想重复造轮子,所以肯定也有工具类,就是它了:Guava 我将举例几个实际的例子,发挥这个工具类好用的功能.更多的方法和功能,还有内部的实现可以直接参考http ...