Docker Community Forums

Share and learn in the Docker community.

Error in creating container

I tried to run container

by using this command
docker run --rm -it -p 8080:80 -v /code:/var/www/myapp myapp/jelo:latest

but I got an error

[emerg] open() “/run/nginx/nginx.pid” failed (2: No such file or directory)

Here is my Dockerfile

   FROM php:7.4-fpm-alpine
    #RUN docker-php-ext-install pdo
    RUN docker-php-ext-install pdo_mysql
    RUN apk update \
       &&  apk add --no-cache nginx

    COPY . /var/www/myapp
    ADD default.conf /etc/nginx/conf.d/default.conf

    EXPOSE 9000
    CMD ["nginx", "-g", "daemon off;"]

Here is my default.confg

server {
        listen  80;
         index index.php;
         server_name myapp.local;
         error_log  /var/log/nginx/error.log;
         access_log /var/log/nginx/access.log;
         root /var/www/myapp;

          location / {
             try_files $uri $uri/ /index.php?$args;
           }

        
         location ~ \.php$ {
                 try_files $uri =404;
                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
                 fastcgi_index index.php;
                 fastcgi_pass php:9000;
                 include fastcgi_params;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                 fastcgi_param PATH_INFO $fastcgi_path_info;
             }
     }

Thank you in advance