I try to create an image from the image jelastic/nginxphp:1.18.0-php-7.4.10
to set up my existing Laravel project (to then put on Jelastic cloud). However, when I try to access localhost I get a ERR_EMPTY_RESPONSE
error.
I also tried to create a container from the jelastic/nginxphp:1.18.0-php-7.4.10
image but I have the same error
my Dockerfile
# ---------- Base ----------
FROM jelastic/nginxphp:1.18.0-php-7.4.10 AS base
# Set main params. The value local is equal to dev
ARG user=runner
ARG BUILD_ENV=local
ARG BUILD_DEBUG=true
ENV APP_HOME /var/www/webroot/ROOT
ENV ENV=$BUILD_ARGUMENT_ENV
ENV DEBUG_ENABLED=$BUILD_DEBUG
# it's the same configuration as the basic one but with the following changes
# /var/www/webroot/ROOT -> /var/www/webroot/ROOT/public
COPY docker-conf/nginx/conf.d/nginx.conf /etc/nginx/nginx.conf
# Enable PHP extension
RUN yum install -y sed
RUN sed -i "s|;extension=pdo_mysql.so|extension=pdo_mysql.so|g" /etc/php.ini
# ---------- Builder ----------
FROM base as build
# Set working directory
WORKDIR $APP_HOME
COPY . .
RUN if [ "$BUILD_ARGUMENT_ENV" = "production" ];then COMPOSER_MEMORY_LIMIT=-1 composer update --optimize-autoloader --no-interaction --no-progress --no-dev; \
else COMPOSER_MEMORY_LIMIT=-1 composer update --optimize-autoloader --no-interaction --no-progress; \
fi
# Create system user
RUN useradd -ms /bin/bash $user
USER $user
the error produced
When I lauch this commande docker build -t myimage/backend .
, I have this result:
[+] Building 278.0s (13/13) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 34B 0.0s
=> [internal] load metadata for docker.io/jelastic/nginxphp:1.18.0-php-7.4.10 0.0s
=> [base 1/4] FROM docker.io/jelastic/nginxphp:1.18.0-php-7.4.10 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 26.72kB 0.1s
=> CACHED [base 2/4] COPY docker-conf/nginx/conf.d/nginx.conf /etc/nginx/nginx.conf 0.0s
=> [base 3/4] RUN yum install -y sed 27.8s
=> [base 4/4] RUN sed -i "s|;extension=pdo_mysql.so|extension=pdo_mysql.so|g" /etc/php.ini 0.5s
=> [build-app 1/4] WORKDIR /var/www/webroot/ROOT 0.0s
=> [build-app 2/4] COPY . . 0.1s
=> [build-app 3/4] RUN if [ "$BUILD_ARGUMENT_ENV" = "production" ];then COMPOSER_MEMORY_LIMIT=-1 composer update --optimize-autoloader --no-interaction --no-progress --no-dev; else COMPOSER_MEMORY_LIMIT=-1 composer upd 245.9s
=> [build-app 4/4] RUN useradd -ms /bin/bash runner 0.5s
=> exporting to image 3.0s
=> => exporting layers 2.9s
=> => writing image sha256:98c32ac25564198547a767153df9c410467aabdf64c9115158c301272f2de3cc 0.0s
=> => naming to docker.io/myimage/backend
Here is the command I use to create a container:
C:\Users\Myusername\Documents\projet>docker run -dp 8000:80 myimage/backend
c5c00082d17677bfb599decab892e18de468ab13380ed1d23a38cbf3c06511ee
When I lauch this command: docker run -dp 8000:80 jelastic/nginxphp:1.18.0-php-7.4.10
, I have the same error
here is my configuration file for the nginx server
#user nobody;
worker_processes auto;
worker_rlimit_nofile 2048;
#load_module modules/ngx_http_modsecurity_module.so;
error_log /var/log/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 2048;
}
http {
server_tokens off;
include mime.types;
default_type application/octet-stream;
client_max_body_size 100m;
log_format main '$remote_addr:$http_x_remote_port - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$host" sn="$server_name" '
'rt=$request_time '
'ua="$upstream_addr" us="$upstream_status" '
'ut="$upstream_response_time" ul="$upstream_response_length" '
'cs=$upstream_cache_status' ;
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
gzip_types text/plain text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript;
# Websocket support
#upstream websocket {
# server 127.0.0.1:<PORT>;
#}
server {
listen 80;
listen [::]:80;
server_name _;
#charset koi8-r;
access_log /var/log/nginx/host.access.log;
include /etc/nginx/aliases.conf;
#location /ws {
# proxy_pass http://websocket;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "Upgrade";
#}
if ($http_x_remote_port = '' ) {
set $http_x_remote_port $remote_port;
}
#modsecurity on;
#modsecurity_rules_file /etc/nginx/conf.d/modsecurity/modsec_includes.conf;
location / {
root /var/www/webroot/ROOT/public;
index index.html index.htm index.php;
location ~ \.php$ {
location ~ /\. { deny all; access_log off; log_not_found off; }
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}
index index.php index.html index.htm;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
proxy_pass http://127.0.0.1;
}
location ~ ^/\.well-known { root /var/www/webroot/ROOT; allow all;}
location ~ /\.well-known { root /var/www/webroot; allow all;}
location ~ /\. { deny all; access_log off; log_not_found off; }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location ~ \.php$ {
location ~ /\. { deny all; access_log off; log_not_found off; }
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.socket;
fastcgi_param SCRIPT_FILENAME /var/www/webroot$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT /var/www/webroot;
}
}
include /etc/nginx/conf.d/*.conf;
}