Answer the question
In order to leave comments, you need to log in
Why can't I run docker bundle nginx+php-fpm?
Good afternoon.
I'm just studying the issue - so far there are no goals to mount the directory. Trying to get rid of error 502 (at localhost:8080 ).
1. There is a project structure
1.1. I have a config file for nginx ( localhost:8080 )
server {
listen 80;
charset utf-8;
index index.php index.html;
root /app/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_read_timeout 300;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
<?php
print "Hi!";
?>
FROM nginx:1.17-alpine
#COPY ./docker/nginx/conf.d /etc/nginx/conf.d
COPY ./././docker/nginx/conf.d ./etc/nginx/conf.d
#COPY ./public ./public
COPY ./public ./app/public
WORKDIR /app
docker build --file=site/docker/nginx/Dockerfile --tag=site-nginx site
docker build --file=site/docker/php-fpm/Dockerfile --tag=site-php-fpm site
docker network create site
docker run -d --network site --name php-fpm site-php-fpm
docker run -d --network site --name nginx -p 8080:80 site-nginx
Answer the question
In order to leave comments, you need to log in
If you make two different containers with your hands and they must be linked, but for some reason you don’t want to use docker-compose, don’t forget to link between them. example.
1. took off first
docker run -d --network site --name one -P nginxdemos/hello
docker run -d --network site --name two --link one -P nginxdemos/hello
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40132d06643d nginxdemos/hello "nginx -g 'daemon of…" 3 seconds ago Up 1 second 0.0.0.0:32772->80/tcp two
5b6100f38e7d nginxdemos/hello "nginx -g 'daemon of…" 56 seconds ago Up 54 seconds 0.0.0.0:32771->80/tcp one
docker exec -it 5b6 /bin/sh
/ # ping one
PING one (172.18.0.2): 56 data bytes
64 bytes from 172.18.0.2: seq=0 ttl=64 time=0.081 ms
64 bytes from 172.18.0.2: seq=1 ttl=64 time=0.128 ms
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question