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

205
Visualizações
Problems in setting up a Docker application with php, apache and native DB

I need to build a docker application with just php and apache as containers to run a php-based web application. I am using only Docker Compose YAML files which I can active in a specific UI - I don't work with all the command line stuff (it's a NAS with a modified Linux-based OS where I typically avoid any activities on command line level).

Both images of php and apache should be based on the latest version and for sure communicate to each other. The database to be used should be the native MariaDB of the machine.

I've been trying many dozens of variations of a Docker Compose YAML file, but so far none is working even in the basic operations:

version: "3.1"
services:
  php:
    image: php:latest
    working_dir: /root
    volumes:
      - /share/Web/myWebApp:/root
    command: docker-php-ext-install pdo pdo_mysql
    links:
      - "web"

  web:
    image: httpd:latest
    volumes:
      - /share/Web/myWebApp:/usr/local/apache/htdocs
    ports:
      - 9500:80
      - 9501:443

With the above YAML file, teh application starte to be created, and the php-command

command: docker-php-ext-install pdo pdo_mysql

causes a longer output to appear from php, but once it's finished, the php container immediately stops. When I leave out this command, the container doesn't even start at all. I'm not sure about the

working_dir

instruction for php as well. Is this needed at all? If so, what would it have to be, an internal volume or mapped to a host volume (as above)?

The apache Webserver-container, however, starts and can be launched by the host URL:9500, showing "It works", but it ignores the mapping

/share/Web/myWebApp:/usr/local/apache/htdocs

which I have specified. It only displays the static INDEX.HTML file provided by apache. When I go into the running apache container (via command line), I can move to the directory

/usr/local/apache/htdocs

and this in fact contains all the HTML and PHP files of my web application, but when I launch the URL:PORT in the browser, only the fix INDEX.HTML is being displayed.

This must be a million-times question since this is a very basic setup, but I don't get it to work. Also I am confused by the networking instructions fo Docker Compose. The documentation says that the use of

links

is deprecated, but anyway not needed since the containers can natively communicate to each other, iving in the same Docker network. Instead

networks

should rather be used, but I'm confused whether I need that at all?

If anyone may have an example of a basic YAM file that does the job or give me a hint of what is wrong in mine would be very much appreciated.

over 4 years ago · Santiago Trujillo
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