docker icon indicating copy to clipboard operation
docker copied to clipboard

Nginx return 404

Open ezawadzki opened this issue 2 years ago • 13 comments

Description

When I try to connect to localhost:8080, nginx is returning me a 404.

Here are some relevant docker-compose logs :

web_1       | 2021-09-21 14:56:53,943 INFO supervisord started with pid 1
web_1       | 2021-09-21 14:56:54,944 INFO spawned: 'nginx' with pid 8
web_1       | 2021-09-21 14:56:54,946 INFO spawned: 'php-fpm' with pid 9
web_1       | nginx: [alert] could not open error log file: open() "/var/lib/nginx/logs/error.log" failed (13: Permission denied)
web_1       | [21-Sep-2021 14:56:55] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
web_1       | [21-Sep-2021 14:56:55] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
web_1       | [21-Sep-2021 14:56:55] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
web_1       | [21-Sep-2021 14:56:55] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
web_1       | [21-Sep-2021 14:56:55] NOTICE: fpm is running, pid 9
web_1       | [21-Sep-2021 14:56:55] NOTICE: ready to handle connections
web_1       | 2021-09-21 14:56:56,012 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
web_1       | 2021-09-21 14:56:56,012 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
web_1       | 172.23.0.1 - - [21/Sep/2021:14:59:12 +0000] "GET / HTTP/1.1" 404 117 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0" "-" 0.000 - . -

Steps to reproduce

Just execute docker-compose up on suggested docker-compose.yml.

Additional info

  • image: craftcms/nginx:8.0-dev

  • image: craftcms/cli:8.0-dev

  • image: postgres:13-alpine

  • image: redis:5-alpine

  • Docker-compose file : 3.6

  • docker: 20.10.8

  • docker-compose: 1.29.2

  • Debian : Linux debian 5.10.0-0.bpo.8-amd64

Thanks for your help.

ezawadzki avatar Sep 21 '21 15:09 ezawadzki

Why was this closed? I have the same issue currently, as well as postgres yelling at me that role "root" does not exist.

fangmarks avatar Dec 25 '21 12:12 fangmarks

I have the same issue here too

mikejdegroot avatar Jan 04 '22 10:01 mikejdegroot

Also experiencing the same issue. Some further explanation to get up and running in the readme for docker newbies could be helpful as well.

leightonhughes avatar Jan 14 '22 00:01 leightonhughes

I'm still unable to reproduce this. To ensure we're all on the same page, can you clone this repo and follow the instructions in the README?

https://github.com/timkelty/craftcms-docker-compose

note: the role "root" does not exist. from postgres is a red herring.

timkelty avatar Jan 14 '22 14:01 timkelty

I managed to get this up and running by initialising a craft installation as usual, then adding the docker-compose yaml and Dockerfile as suggested in this readme. The role "root" does not exist issue is solvable via adding the user to the pg_isready command as : test: pg_isready -U craftcms -d dev_craftcms

mikejdegroot avatar Jan 14 '22 14:01 mikejdegroot

you will also need to exec into the shell once its up and running with docker-compose exec web sh and then run ./craft install to install craft to the db

mikejdegroot avatar Jan 14 '22 14:01 mikejdegroot

you will also need to exec into the shell once its up and running with docker-compose exec web sh and then run ./craft install to install craft to the db

Yes, or you can do it via the web interface (will prompt you on first visit to /admin)

timkelty avatar Jan 14 '22 14:01 timkelty

The role "root" does not exist issue is solvable via adding the user to the pg_isready command as : test: pg_isready -U craftcms -d dev_craftcms

Good call, I'll update the example compose file

timkelty avatar Jan 14 '22 14:01 timkelty

I'm also getting 404's. Maybe I am misunderstanding the instructions?

In new directory: using the docker-compose.yml from https://github.com/craftcms/docker#running-locally-with-docker-compose.
Tried image: craftcms/...:8.0 and image: craftcms/...:8.1.

I copied the .env.example (although I don't think it is used in the docker compose file), and I run docker compose up.

I get:

  • exit code for console ("could not open input file: craft")
  • 404 messages for localhost:8080/admin (and /)

When I check the container, there's nothing in the /app folder (so: can't run ./craft install)

$ docker exec -it craftcms-web-1 sh

/app $ ls -l
total 0
craftcms-postgres-1  | 2023-05-01 11:28:34.307 UTC [1] LOG:  database system is ready to accept connections
craftcms-console-1   | Could not open input file: craft
craftcms-console-1 exited with code 1
craftcms-web-1       | 2023-05-01 11:29:04,098 INFO supervisord started with pid 1
craftcms-web-1       | 2023-05-01 11:29:05,107 INFO spawned: 'nginx' with pid 7
craftcms-web-1       | 2023-05-01 11:29:05,113 INFO spawned: 'php-fpm' with pid 8
craftcms-web-1       | nginx: [alert] could not open error log file: open() "/var/lib/nginx/logs/error.log" failed (13: Permission denied)
craftcms-web-1       | [01-May-2023 11:29:05] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
craftcms-web-1       | [01-May-2023 11:29:05] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
craftcms-web-1       | [01-May-2023 11:29:05] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
craftcms-web-1       | [01-May-2023 11:29:05] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
craftcms-web-1       | [01-May-2023 11:29:05] NOTICE: fpm is running, pid 8
craftcms-web-1       | [01-May-2023 11:29:05] NOTICE: ready to handle connections
craftcms-web-1       | 2023-05-01 11:29:06,253 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
craftcms-web-1       | 2023-05-01 11:29:06,253 INFO success: php-fpm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

craftcms-web-1       | 172.24.0.1 - - [01/May/2023:11:29:14 +0000] "GET /admin HTTP/1.1" 404 178 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" "-" 0.000 - . -
craftcms-web-1       | 172.24.0.1 - - [01/May/2023:11:29:20 +0000] "GET / HTTP/1.1" 404 178 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36" "-" 0.000 - . -

wivaku avatar May 01 '23 11:05 wivaku

@wivaku These docker images only provide the environment required to run Craft, not any of the actual application files.

If you don't have an existing Craft app, you can start one via composer create-project craftcms/craft my-project.

There more in-depth guides here, but those focus on using DDEV for local development.

timkelty avatar May 01 '23 15:05 timkelty

ah, ok. Thanks.

wivaku avatar May 01 '23 17:05 wivaku

Hi, I have created a local project and was able to build a image with dependencies. But when i use this image to run container on ECS, the dependent files are missing and it gives me 404 error. Anyone able to run craftcms on ECS?

nagarjuna-jammula avatar Mar 05 '24 09:03 nagarjuna-jammula

@nagarjuna-jammula Hmmm, yes we run them on ECS regularly… if you can share more details, or send to [email protected], we may be able to point you in the right direction.

timkelty avatar Mar 05 '24 13:03 timkelty