V
V
Vadim2019-11-24 16:19:57
PHP
Vadim, 2019-11-24 16:19:57

Why does PHP require Apache or Nginx to run in a docker container?

Hello everyone,
all tutorials on dockerizing php require you to run it from an image that contains Apache or Nginx, for example, the line from the Dockerfile
FROM php:7.1.8-apache
what's the point of using Apache or Nginx containing an image? Isn't it possible to work with a container containing only php?
thanks, Vadim

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maksim Fedorov, 2019-11-24
@Viji

what's the point of using Apache or Nginx containing the image? Isn't it possible to work with a container containing only php?

You can. You can put a PHP-CLI container and work with it without a web server, of course.
Which will allow you to run console commands (composer there too)
If you install a PHP-FPM container, then of course you need a web server (google the principle of working with Fast CGI ).
Required if you want to communicate with the application via HTTP
FROM php:7.1-fpm

E
entermix, 2019-11-24
@entermix

You can install PHP CLI and use the built-in web server.
https://forums.docker.com/t/running-php-built-in-s...
https://hub.docker.com/_/php/
https://www.php.net/manual/ en/features.commandline...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question