5

I am new to docker and I'm trying to set it up in order to run with Laravel 5.1. I am currently getting the following error

Call to undefined function Illuminate\Foundation\Bootstrap\mb_internal_encoding() in /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:43

I believe this is because the mbstring php extention is not installed. I have tried to add php-mbstring to the Docker file but it doesn't seem to be working.

Here is my full Docker file

FROM php:5.6.30-fpm

    RUN apt-get update && apt-get install -y libmcrypt-dev \
        mysql-client libmagickwand-dev --no-install-recommends \
        && pecl install imagick \
        && docker-php-ext-install mcrypt pdo_mysql \
        && docker-php-ext-install php-mbstring 

I am then running sudo docker compose up from the application folder. This does not seem to be resolving the error though. How do I know if the extensions are being installed properly?

EDIT: I have included the docker-compose.yml file below

version: '2'
services:

  # The Application
  app:
    build:
      context: ./
      dockerfile: app.dockerfile
    working_dir: /var/www
    volumes:
      - ./:/var/www
    environment:
      - "DB_PORT=3306"
      - "DB_HOST=database"

  # The Web Server
  web:
    build:
      context: ./
      dockerfile: web.dockerfile
    working_dir: /var/www
    volumes_from:
      - app
    ports:
      - 8080:80

  # The Database
  database:
    image: mysql:5.6
    volumes:
      - dbdata:/var/lib/mysql
    environment:
      - "MYSQL_DATABASE=homestead"
      - "MYSQL_USER=homestead"
      - "MYSQL_PASSWORD=secret"
      - "MYSQL_ROOT_PASSWORD=secret"
    ports:
        - "33061:3306"

volumes:
  dbdata:
SamBremner
  • 793
  • 2
  • 10
  • 22

2 Answers2

6

Remove the php- prefix and it should work fine. You can also run it on the previous docker-php-ext-install command:

docker-php-ext-install mcrypt pdo_mysql mbstring

Leonardo Prado
  • 598
  • 5
  • 12
  • Thanks for your response. I tried to remove the php- and still getting the same error. Great tip though about running on the previous `docker-php-ext-install`. – SamBremner May 26 '17 at 17:09
  • Odd. Can you post your docker-composer.yml on your question so we can try to recreate the issue? :) – Leonardo Prado May 26 '17 at 18:26
  • I have added the docker-compose.yml file to my question. Please have a look when you get a chance. Thanks. – SamBremner May 30 '17 at 08:26
0

on ubuntu php-mbstring has dependency with php-common and version specific mbstring like php7.1-mbstring that may cause the problem. You can check dependencies with this command below;

apt-cache depends php-mbstring
Emrah Toy
  • 39
  • 1
  • 1
  • 4
  • Thanks for your response, i have tried to find the dependencies from within docker using the command `sudo docker exec -it 81a8f6eea495 apt-cache depends php-mbstring` but it just returns 'No packages found'. I also tried to add common and php-common to the docker file but im still getting the same error. – SamBremner May 26 '17 at 17:08