4
votes

No matter what I try, I keep getting HTTP error code 500 when I visit my docker-machine ip.

I am running laradock through Docker tool box (OS: Windows 10) and have a default VM running. I have setup laradock as per the instructions in the video.

I have successfully mounted the folder that I need into the VM and have changed docker-compose.yml according to the location of my code in the VM:

Here is my docker-compose.yml file:

version: '2'

services:

Nginx Server Container

nginx:
    build: ./nginx
    volumes_from:
        - volumes_source
    volumes:
        - ./logs/nginx/:/var/log/nginx
    ports:
        - "80:80"
        - "443:443"
    links:
        - php-fpm

PHP-FPM Container

php-fpm:
    build:
        context: ./php-fpm
        dockerfile: Dockerfile-70
    volumes_from:
        - volumes_source
    expose:
        - "9000"
    links:
        - workspace

MySQL Container

mysql:
    build: ./mysql
    volumes_from:
        - volumes_data
    ports:
        - "3306:3306"
    environment:
        MYSQL_DATABASE: homestead
        MYSQL_USER: homestead
        MYSQL_PASSWORD: secret
        MYSQL_ROOT_PASSWORD: root

PostgreSQL Container

postgres:
    build: ./postgres
    volumes_from:
        - volumes_data
    ports:
        - "5432:5432"
    environment:
        POSTGRES_DB: homestead
        POSTGRES_USER: homestead
        POSTGRES_PASSWORD: secret

MariaDB Container

mariadb:
    build: ./mariadb
    volumes_from:
        - volumes_data
    ports:
        - "3306:3306"
    environment:
        MYSQL_DATABASE: homestead
        MYSQL_USER: homestead
        MYSQL_PASSWORD: secret
        MYSQL_ROOT_PASSWORD: root

Neo4j Container

neo4j:
    build: ./neo4j
    ports:
        - "7474:7474"
        - "1337:1337"
    environment:
        - NEO4J_AUTH=homestead:secret
    volumes_from:
        - volumes_data

MongoDB Container

mongo:
    build: ./mongo
    ports:
        - "27017:27017"
    volumes_from:
        - volumes_data

Redis Container

redis:
    build: ./redis
    volumes_from:
        - volumes_data
    ports:
        - "6379:6379"

Memcached Container

memcached:
    build: ./memcached
    volumes_from:
        - volumes_data
    ports:
        - "11211:11211"
    links:
        - php-fpm

Beanstalkd Container

beanstalkd:
    build: ./beanstalkd
    ports:
        - "11300:11300"
    privileged: true
    links:
        - php-fpm

Beanstalkd Console Container

beanstalkd-console:
    build: ./beanstalkd-console
    ports:
        - "2080:2080"
    links:
        - beanstalkd

Workspace Utilities Container

workspace:
    build:
        context: ./workspace
        args:
            - INSTALL_PRESTISSIMO=false
    volumes_from:
        - volumes_source
    tty: true

Laravel Application Code Container

volumes_source:
    build: ./volumes/application
    volumes:
        - /c/Users/pomodoro.xyz/code:/var/www/laravel

Databases Data Container

volumes_data:
    build: ./volumes/data
    volumes:
        - /var/lib/mysql:/var/lib/mysql
        - /var/lib/postgres:/var/lib/postgres
        - /var/lib/mariadb:/var/lib/mariadb
        - /var/lib/memcached:/var/lib/memcached
        - /var/lib/redis:/data
        - /var/lib/neo4j:/var/lib/neo4j/data
        - /var/lib/mongo:/data/db

Add more Containers below

When I log into the workspace and change files, they are reflected into the host machine, so I am good on that front.

Here is my folder structure in my work container (just as per the video):

root@d463d55e545b:/var/www/laravel# ls -l
total 30
drwxrwxrwx 1 1000 staff 4096 Jul 20 19:58 app
-rwxrwxrwx 1 1000 staff 1646 Jul 20 19:58 artisan
drwxrwxrwx 1 1000 staff    0 Jul 20 19:58 bootstrap
-rwxrwxrwx 1 1000 staff 1272 Jul 20 19:58 composer.json
drwxrwxrwx 1 1000 staff 4096 Jul 20 19:58 config
drwxrwxrwx 1 1000 staff 4096 Jul 20 19:58 database
-rwxrwxrwx 1 1000 staff  503 Jul 20 19:58 gulpfile.js
-rwxrwxrwx 1 1000 staff   12 Jul 21 15:13 index.html
drwxrwxrwx 1 1000 staff 4096 Jul 23 09:24 laradock
-rwxrwxrwx 1 1000 staff  212 Jul 20 19:58 package.json
-rwxrwxrwx 1 1000 staff 1026 Jul 20 19:58 phpunit.xml
drwxrwxrwx 1 1000 staff 4096 Jul 23 10:39 public
-rwxrwxrwx 1 1000 staff 1918 Jul 20 19:58 readme.md
drwxrwxrwx 1 1000 staff    0 Jul 20 19:58 resources
-rwxrwxrwx 1 1000 staff  567 Jul 20 19:58 server.php
drwxrwxrwx 1 1000 staff    0 Jul 20 19:58 storage
drwxrwxrwx 1 1000 staff    0 Jul 20 19:58 tests
drwxrwxrwx 1 1000 staff    0 Jul 20 19:59 vendor

All nginx.conf files etc are being loaded into the container as I can see from docker exec -it into my nginx container.

For reference, here is my laravel.conf

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;

root /var/www/laravel/public;
index index.php index.html index.htm;

server_name laravel.dev www.laravel.dev;

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

location ~ \.php$ {
    try_files $uri /index.php =404;
    fastcgi_pass php-upstream;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}

}

and nginx.conf:

user www-data; worker_processes 4; pid /run/nginx.pid;

events { worker_connections 2048; multi_accept on; use epoll; }

http { server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 15; types_hash_max_size 2048; client_max_body_size 20M; include /etc/nginx/mime.types; default_type application/octet-stream; access_log on; error_log on; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/.conf; include /etc/nginx/sites-available/; open_file_cache max=100; }

daemon off;

And here is my laravel's root directory's .env file:

APP_ENV=local APP_DEBUG=true APP_KEY=SomeRandomString APP_URL=http://localhost

DB_CONNECTION=mysql DB_HOST=192.168.99.100 DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret

CACHE_DRIVER=file SESSION_DRIVER=file QUEUE_DRIVER=sync

REDIS_HOST=192.168.99.100 REDIS_PASSWORD=null REDIS_PORT=6379

MAIL_DRIVER=smtp MAIL_HOST=mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null

I have also setup the permissions of the folder by logging into the workspace container and typing:

chmod -R 777 storage bootstrap/cache

But still I keep getting the http 500 error on docker-machine ip. What am I missing?

1
Are you sure you are using the right docker-machine ip?enderland
Yes. I ran docker-machine ip default to get my IP address.stirredo

1 Answers

0
votes

A potential problem I see is that you use IP addresses for your service hosts (DB_HOST, REDIS_HOST) in your .env. Potentially these IP addresses can change and it is therefore safer to use the container names as host address. In your case youll want to use "DB_HOST=mysql" and "REDIS_HOST=redis".

The http 500 means there is probably nothing wrong with your nginx config and sounds more like a Laravel configuration problem. I suggest you inspect your laravel log file (storage/logs/laravel.log) for more information.