0

I try to install laravel 5.0/mysql"5.5"/php_version under docker and I can not site in browser and make seeding of app: I have 3 config files: docker-compose.yml :

version: '3.1'

services:

    youtube_api_demo_app:
        build:
            context: ./web
            dockerfile: Dockerfile.yml

        container_name: youtube_api_demo_app_container
        environment:
            - APACHE_RUN_USER=#1000
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        ports:
            - 8085:80
        working_dir: ${APP_PTH_CONTAINER}


    db:
        image: mysql:5.5.62
        restart: always
        environment: 
            MYSQL_ROOT_PASSWORD: 1
        volumes:
            - ${DB_PATH_HOST}:/var/lib/mysql


    adminer:
        image: adminer
        restart: always
        ports:
            - 8086:8080
        links:
            - db


    youtube_api_demo_composer:
        image: composer:1.6
        container_name: youtube_api_demo_composer_container
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        working_dir: ${APP_PTH_CONTAINER}
        command: composer install --ignore-platform-reqs

.env:

# PATHS
DB_PATH_HOST=./databases
APP_PATH_HOST=./YoutubeAPI_Demo
APP_PTH_CONTAINER=/var/www/html/

web/Dockerfile.yml:

FROM php:5.6-apache
RUN apt-get update -y && apt-get install -y libpng-dev   nano  libmcrypt-dev
RUN docker-php-ext-install \
    pdo_mysql \
    mcrypt \
    && a2enmod \
    rewrite

and env of my app /YoutubeAPI_Demo/.env :

APP_NAME=Laravel APP_ENV=local APP_KEY=base64:4+BRJbKtSQ7Z7yBVkYxe+NxfLkVPBAG2Gm1I93Qwukc= APP_DEBUG=true APP_URL=http://127.0.0.1:8085/ APP_SUBDIRECTORY=

LOG_CHANNEL=stack

DB_USERNAME=root DB_PASSWORD=1 DB_CONNECTION=mysql DB_HOST=127.0.0.1:8086 DB_PORT=:8086 DB_DATABASE=youtube_api_demo

I am not sure if I set valid DB_HOST and DB_PORT parameters, actually I tried different.

1) I builded the app and entered the console, but I got error migrating:

# php artisan migrate                                                           
  [PDOException]                             
  SQLSTATE[HY000] [2002] Connection refused

But I entered adminer and created the db: https://i.sstatic.net/SbzYu.jpg

2) Entering in browser http://127.0.0.1:8085/ I got error :

You don't have permission to access / on this server.
Apache/2.4.25 (Debian) Server at 127.0.0.1 Port 8085 


 docker ps
CONTAINER ID        IMAGE                                  COMMAND                  CREATED             STATUS                          PORTS                    NAMES
a51ccd12ae40        adminer                                "entrypoint.sh docke…"   About an hour ago   Up About an hour                0.0.0.0:8086->8080/tcp   youtubeapi_demo_adminer_1
7f9ee8f14c9d        mysql:5.5.62                           "docker-entrypoint.s…"   About an hour ago   Up About an hour                3306/tcp                 youtubeapi_demo_db_1
b2c47edaf616        youtubeapi_demo_youtube_api_demo_app   "docker-php-entrypoi…"   About an hour ago   Up About an hour                0.0.0.0:8085->80/tcp     youtube_api_demo_app_container
3dcc1a4ce8f0        adminer                                "entrypoint.sh docke…"   5 weeks ago         Up 4 hours                      0.0.0.0:8083->8080/tcp   lprods_adminer_container
933d9fffaf76        postgres:9.6.10-alpine                 "docker-entrypoint.s…"   5 weeks ago         Up 4 hours                      0.0.0.0:5433->5432/tcp   lprods_db_container
2f73a600b999        adminer                                "entrypoint.sh docke…"   6 weeks ago         Up 4 hours                      0.0.0.0:8082->8080/tcp   votes_docker_adminer_1
52ea479b8791        mysql:5.6.41                           "docker-entrypoint.s…"   6 weeks ago         Restarting (1) 34 seconds ago                            votes_docker_db_1

What are wrong in config options ?

Thanks!

1 Answer 1

2

1) In .env: you can use :

DB_CONNECTION=mysql
DB_HOST=db // THAT IS MYSQL container name
DB_PORT=3306

2) Try url

http://127.0.0.1:8085/public

with usual laravel 5 dirs settings

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.