502 Bad Gateway with dockerized PHP-FPM










0















I'm trying to replace my PHP-FPM installation with a docker container.
I can build a container and start the FPM service (127.0.0.1:9000).



However, I get a Bad Gateway (502) error when I enter the connection in nginx.
What could be the reason?



Dockerfile



FROM alpine:latest

RUN apk --update --no-cache add
php7
php7-bcmath
php7-dom
php7-ctype
php7-simplexml
php7-session
php7-soap
php7-tokenizer
php7-xml
php7-xmlreader
php7-xmlwriter
php7-zip
&& rm -rf /var/cache/apk/*

#COPY php.ini /etc/php7/conf.d/50-setting.ini
COPY php-fpm.conf /etc/php7/php-fpm.conf

EXPOSE 9000

CMD ["php-fpm7", "-F"]


php-fpm.conf



[global]
error_log = /dev/stderr

[default]
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 400


Building and running



docker build -t php-fpm .
docker run --user="$(id -u www-data)" --name=php-fpm --rm -it -p 127.0.0.1:9000:9000 php-fpm:latest

[14-Nov-2018 13:35:23] NOTICE: fpm is running, pid 1
[14-Nov-2018 13:35:23] NOTICE: ready to handle connections


NGINX PHP Settings



include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;









share|improve this question






















  • Is your nginx running in a container as well? Are they both part of the same Docker network?

    – Oldskool
    Nov 14 '18 at 13:58












  • nginx comes from the debian repositories. i wanted to keep it that way for now, because the dependencies are relatively small

    – br0ken.pipe
    Nov 14 '18 at 14:01















0















I'm trying to replace my PHP-FPM installation with a docker container.
I can build a container and start the FPM service (127.0.0.1:9000).



However, I get a Bad Gateway (502) error when I enter the connection in nginx.
What could be the reason?



Dockerfile



FROM alpine:latest

RUN apk --update --no-cache add
php7
php7-bcmath
php7-dom
php7-ctype
php7-simplexml
php7-session
php7-soap
php7-tokenizer
php7-xml
php7-xmlreader
php7-xmlwriter
php7-zip
&& rm -rf /var/cache/apk/*

#COPY php.ini /etc/php7/conf.d/50-setting.ini
COPY php-fpm.conf /etc/php7/php-fpm.conf

EXPOSE 9000

CMD ["php-fpm7", "-F"]


php-fpm.conf



[global]
error_log = /dev/stderr

[default]
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 400


Building and running



docker build -t php-fpm .
docker run --user="$(id -u www-data)" --name=php-fpm --rm -it -p 127.0.0.1:9000:9000 php-fpm:latest

[14-Nov-2018 13:35:23] NOTICE: fpm is running, pid 1
[14-Nov-2018 13:35:23] NOTICE: ready to handle connections


NGINX PHP Settings



include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;









share|improve this question






















  • Is your nginx running in a container as well? Are they both part of the same Docker network?

    – Oldskool
    Nov 14 '18 at 13:58












  • nginx comes from the debian repositories. i wanted to keep it that way for now, because the dependencies are relatively small

    – br0ken.pipe
    Nov 14 '18 at 14:01













0












0








0








I'm trying to replace my PHP-FPM installation with a docker container.
I can build a container and start the FPM service (127.0.0.1:9000).



However, I get a Bad Gateway (502) error when I enter the connection in nginx.
What could be the reason?



Dockerfile



FROM alpine:latest

RUN apk --update --no-cache add
php7
php7-bcmath
php7-dom
php7-ctype
php7-simplexml
php7-session
php7-soap
php7-tokenizer
php7-xml
php7-xmlreader
php7-xmlwriter
php7-zip
&& rm -rf /var/cache/apk/*

#COPY php.ini /etc/php7/conf.d/50-setting.ini
COPY php-fpm.conf /etc/php7/php-fpm.conf

EXPOSE 9000

CMD ["php-fpm7", "-F"]


php-fpm.conf



[global]
error_log = /dev/stderr

[default]
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 400


Building and running



docker build -t php-fpm .
docker run --user="$(id -u www-data)" --name=php-fpm --rm -it -p 127.0.0.1:9000:9000 php-fpm:latest

[14-Nov-2018 13:35:23] NOTICE: fpm is running, pid 1
[14-Nov-2018 13:35:23] NOTICE: ready to handle connections


NGINX PHP Settings



include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;









share|improve this question














I'm trying to replace my PHP-FPM installation with a docker container.
I can build a container and start the FPM service (127.0.0.1:9000).



However, I get a Bad Gateway (502) error when I enter the connection in nginx.
What could be the reason?



Dockerfile



FROM alpine:latest

RUN apk --update --no-cache add
php7
php7-bcmath
php7-dom
php7-ctype
php7-simplexml
php7-session
php7-soap
php7-tokenizer
php7-xml
php7-xmlreader
php7-xmlwriter
php7-zip
&& rm -rf /var/cache/apk/*

#COPY php.ini /etc/php7/conf.d/50-setting.ini
COPY php-fpm.conf /etc/php7/php-fpm.conf

EXPOSE 9000

CMD ["php-fpm7", "-F"]


php-fpm.conf



[global]
error_log = /dev/stderr

[default]
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 400


Building and running



docker build -t php-fpm .
docker run --user="$(id -u www-data)" --name=php-fpm --rm -it -p 127.0.0.1:9000:9000 php-fpm:latest

[14-Nov-2018 13:35:23] NOTICE: fpm is running, pid 1
[14-Nov-2018 13:35:23] NOTICE: ready to handle connections


NGINX PHP Settings



include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;






php docker nginx dockerfile






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 13:38









br0ken.pipebr0ken.pipe

169217




169217












  • Is your nginx running in a container as well? Are they both part of the same Docker network?

    – Oldskool
    Nov 14 '18 at 13:58












  • nginx comes from the debian repositories. i wanted to keep it that way for now, because the dependencies are relatively small

    – br0ken.pipe
    Nov 14 '18 at 14:01

















  • Is your nginx running in a container as well? Are they both part of the same Docker network?

    – Oldskool
    Nov 14 '18 at 13:58












  • nginx comes from the debian repositories. i wanted to keep it that way for now, because the dependencies are relatively small

    – br0ken.pipe
    Nov 14 '18 at 14:01
















Is your nginx running in a container as well? Are they both part of the same Docker network?

– Oldskool
Nov 14 '18 at 13:58






Is your nginx running in a container as well? Are they both part of the same Docker network?

– Oldskool
Nov 14 '18 at 13:58














nginx comes from the debian repositories. i wanted to keep it that way for now, because the dependencies are relatively small

– br0ken.pipe
Nov 14 '18 at 14:01





nginx comes from the debian repositories. i wanted to keep it that way for now, because the dependencies are relatively small

– br0ken.pipe
Nov 14 '18 at 14:01












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301566%2f502-bad-gateway-with-dockerized-php-fpm%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53301566%2f502-bad-gateway-with-dockerized-php-fpm%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

Evgeni Malkin