将docker

编程入门 行业动态 更新时间:2024-10-25 03:19:51
本文介绍了将docker-compose.yml中的软件包安装到docker容器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是docker和docker-compose的初学者,需要您的帮助。

I am a beginner with docker and docker-compose and i need your help.

我正在使用docker-compose开发PHP-NGINX-PostgresSQL symfony开发环境。

I'm making PHP-NGINX-PostgresSQL symfony developement environment using docker-compose.

这里是:

web: image: nginx:1.13.5 ports: - "80:80" volumes: - ./html:/html - ./site.conf:/etc/nginx/conf.d/default.conf links: - php php: image: php:7-fpm volumes: - ./html:/html links: - postgres postgres: image: postgres:9.6.5 ports: - "5432:5432" environment: POSTGRES_PASSWORD: postgres

现在,我会想要将php7.2-intl安装到我的php容器中。所以我想执行以下命令:

Now, i would like to install php7.2-intl into my php container. So i would like to execute something like :

$ sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install php7.2-intl

你能帮我吗?我真的很困,也没有Dockerfile文件,只有docker-compose.yml文件。

Could you help me? I'm really stuck and also I dont have a Dockerfile file, just a docker-compose.yml file.

推荐答案

一个具有intl扩展名的PHP docker容器,您需要扩展正式的PHP映像。

To get a PHP docker container with the intl extension, you need to extend the official PHP image.

为此,声明使用您自己的 Dockerfile 用于 docker-compose.yml中的PHP映像

To do so, declare the use of your own Dockerfile for your PHP image in docker-compose.yml:

services: php: # Remove this line # image: php:7-fpm # Add this one instead build: './docker/php' # ...

然后,添加以下 Dockerfile 文件添加到 docker / php 文件夹中:

Then, add the following Dockerfile file to the docker/php folder:

FROM php:7.1-fpm RUN apt-get update && apt-get install -y \ libicu-dev \ && docker-php-ext-install \ intl \ && docker-php-ext-enable \ intl

您现在可以运行 docker-compose build 使您的PHP容器使用Intl扩展名构建。

You can now run docker-compose build to get your PHP container built with the Intl extension.

一些注意事项:

  • 我更愿意明确说明我使用的PHP版本(此处为 7.1.x),而不是用 php:7-fpm 。
  • 我更喜欢使用 docker-php-ext-install 和 docker-php-ext-enable 命令实用程序(请参见 PHP映像文档)。
  • I prefer to explicitly tell which PHP version I use (here "7.1.x") rather than the more generic "7.x" you defined with php:7-fpm.
  • I preferred to use the docker-php-ext-install and docker-php-ext-enable command utilities provided by the PHP official image (see "How to install more PHP extensions" section in the PHP image documentation).

更多推荐

将docker

本文发布于:2023-07-05 08:58:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1035470.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!