usabilla / php-docker-template

Docker images for PHP applications, CLI and FPM with shared socket
https://hub.docker.com/r/usabillabv/php
MIT License
177 stars 15 forks source link

Document Docker on k8s specifics #100

Open renatomefi opened 5 years ago

renatomefi commented 5 years ago

Context

There are too many things to consider when deploying a PHP Docker setup in Kubernetes, many of them related to good practices and others due to how PHP is designed, the intent of this issue is to list all of them and match whether we have both solved the issue and documented it.

THE list

 # Considering you have a mount between the nginx and php-fpm containers on `/var/run`
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh","-c","while test -e /var/run/nginx.pid; do sleep 1; done"]
stevenjm commented 5 years ago

Regarding the communication between containers, perhaps also note that Unix socket communication does not need to be bound to the filesystem on Linux (search for "abstract" in http://man7.org/linux/man-pages/man7/unix.7.html). This will even work between containers in the same pod, because the abstract socket namespace is part of the network namespace. Sharing a volume between containers with a socket file is actually unnecessary for this case.

I'm not certain whether both nginx and PHP support using abstract socket names, however.

Also, contrasting "socket" with TCP here is misleading, as TCP sockets are also sockets. The appropriate terminology is "Unix domain socket", or just "Unix socket" for short.

azjezz commented 5 years ago

/cc @tomoki1337