Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

567
Visualizações
Configuration PHP Dockerfile from ubuntu image

I tried to execute docker-compose up with php7-fpm image from docker hub and it wor'ks, so it's my docker which is bad configured, can somehone help me ?

I got a problem using docker-compose with Dockerfile image. I explain you what I need, I need my nginx server which comunicates with php. php should communicates with Mysql database.

I just use a Dockerfile to add modules to php.

Here is my php dockerfile :

FROM ubuntu:18.04

# BLOCK : Make PHP works
RUN apt-get update
RUN apt-get -y install software-properties-common
RUN add-apt-repository ppa:ondrej/php
# FIN BLOCK

RUN apt-get -y update && apt-get install -y \
    php7.0 \
    php7.0-fpm \
    php7.0-mysql \
    php7.0-json \
    php7.0-curl \
    php7.0-sqlite3 \
    php7.0-xml \
    php7.0-bcmath \
    php7.0-zip \
    php7.0-mbstring \
    php-xdebug \
    php-ast

WORKDIR /var/www/html

CMD ["php-fpm"]

EXPOSE 9000

NGINX config

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name localhost;

    index index.php index.html;
    error_log  /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html/public;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

When I execute docker-compose --verbose up I got an exit code

Here is --verbose and architecture file

Screen --verbose

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I am using NGINX Unit as an app server for PHP since a little bit more then 2 years. It makes it easier to use PHP applications running on PHP with NGINX without installing / creating a complex docker container image by yourself.

Here is an example of an UNIT build for Wordpress. But it will work with any other PHP Application as well.

https://github.com/tippexs/unitwp

I would give it a try. The official documentation: https://unit.nginx.org/configuration/#php

But back to your problem:

  1. I would not using Ubuntu 14.04 anymore if not absolutley needed. Use a newer image as your base image.

  2. What package are you using to install PHP7.0? I just used a fresh ubuntu:14.04 docker image and tried to install php7.0 without adding any special repo or ppa.

root@31bb99d337d9:/# apt search "php7"
Sorting... Done
Full Text Search... Done

Can't find any PHP7 package. I know there are some ppa's for PHP7 on Ubuntu14.04.

To make it work with my fresh Ubunut 14.04:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
  1. Your PHP-Image does not include an FCGI-proccesor. Your NGINX configuration needs an fcgi-processor listen on port 9000 in the php container. You are not installing it in your Dockerfile.
root@31bb99d337d9:/# apt search php5-fpm
Sorting... Done
Full Text Search... Done
php5-fpm/trusty-updates,trusty-security 5.5.9+dfsg-1ubuntu4.29 amd64
  server-side, HTML-embedded scripting language (FPM-CGI binary)

You should try to find the fpm for php7 in your container.

The fpm needs some additional configuration in your php container as well as it need to be started on container startup.

If have the chance go into your nginx and / or php container instance and check if the fpm is running and listening on port 9000 to accept connections from the nginx container.

I did that many times in the past and migrated anything to NGINX Unit because its much easier to use it. Give it a try.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda