Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom/parametrized port for fpm #479

Closed
bsramin opened this issue Aug 14, 2017 · 4 comments
Closed

Custom/parametrized port for fpm #479

bsramin opened this issue Aug 14, 2017 · 4 comments

Comments

@bsramin
Copy link

bsramin commented Aug 14, 2017

Would not it be convenient to handle the fpm port (9000) in a custom way? So on compose or on run you can start it with the port we prefer. You would avoid conflicts with xdebug and you could start multiple fpm services on the same web server...

@yosifkit
Copy link
Member

Each FPM running in its own container will not have a port conflict with any other FPM running on the server. There are two ways to handle them.

Run a load balancer like Nginx to proxy to the correct FPM container; this would access each FPM via its container IP at port 9000. This works great since you have to run something that speaks the FPM protocol in order to serve any web requests. This can easily be spread over multiple machines with Docker Swarm mode. This would also prevent any of the FPM ports from being potentially publicly accessible.

Alternatively, with compose you can just map a different host port to the container port. Note that you would still need to run something like Nginx in order to route web requests to the FPM service.

# this would make this FPM service available at port 9001 on the Docker host
  ports:
    - "9001:9000"

# or let Docker choose a high unused port like 32768 to use on the host
  ports:
    - "9000"

@rtur
Copy link

rtur commented Oct 16, 2017

Except if one wanted to use host networking, then there isn't any port mapping happening. I agree with @bsramin , it would be nice to be able to overwrite the 9000.

@tianon
Copy link
Member

tianon commented Dec 23, 2017

If adjusting the default port is required, then as noted in #241, one should simply remove, replace, or adjust the configuration file in question. Something simple like the following should do the trick:

FROM php:7.2-fpm
RUN sed -i 's/:9000/:3001/' /usr/local/etc/php-fpm.d/zz-docker.conf

(which adjusts the port from 9000 to 3001 instead -- this could obviously be done via a custom docker run command as well, something like docker run php:7.2-fpm sh -c 'sed ... && exec php-fpm')

@tianon tianon closed this as completed Dec 23, 2017
@jaltek
Copy link

jaltek commented Jun 29, 2018

@tianon

Thanks. I had the same problem and your sed snippet did the trick.
Just a small correction:

FROM php:7.2-fpm
RUN sed -i 's/9000/3001/' /usr/local/etc/php-fpm.d/zz-docker.conf

There are no colons in the zz-docker.conf :)

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants