how to diagnose 404 not found error nginx on docker?

koalaok picture koalaok · Oct 15, 2016 · Viewed 14.7k times · Source

I'm trying to make working out laradock (docker+laravel) following: https://github.com/LaraDock/laradock instructions

I installed docker + cloned laradock.git laradock folder is located at /myHD/...path../www/laradock at the same level I have my laravel projects /myHD/...path../www/project01

I edited laradock/docker-compose.xml

### Laravel Application Code Container ######################

volumes_source:
    image: tianon/true
    volumes:
        - ../project01/:/var/www/laravel

After this, bu I'm not sure it this is how to reload correctly after editing docker-file, I did:

 docker-compose up -d nginx mysql

now since I have a nginx error 404 not found: how can I debug the problem ?

Additional info:

I entered the machine via bash:

 docker-compose exec  --user=laradock workspace bash

but I cant find

 /etc/nginx/... path (nginx folder doesn't exists !?!?) 

Answer

dev_a.y picture dev_a.y · Oct 15, 2016

Guessing your nginx is not located in the workspace container, it resides on a separate container, You've executed the following: docker-compose up -d nginx mysql

That would probably only run nginx and mysql containers, not your php-fpm container. Also the path to you volume is important as the configurations in you nginx server depends on this.

To run php-fpm, add php-fpm or something similar to the docker-compose up command, check out what this is called in your docker-compose.yaml file e.g
docker-compose up -d nginx mysql phpfpm

To assess you nginx container first of all execute

 `docker ps -a`

From the list, look for the ID of your nginx container, before running

docker exec -it <container-id> bash

This should then give you assess to your nginx container to make the required changes.

Or without directly accessing the container, simply make changes in the nginx configuration file, look for 'server' and the 'root' change the root from var/www/laravel/public to the new directory /project01/public.

Execute the command to bring down your containers

docker-composer down

Star over again with

docker-compose up -d nginx mysql phpfpm 

Give it a go