1

I am trying to run below project with docker.

https://github.com/kyleferguson/laravel-with-docker-example

which has the below docker file.

FROM php:7-fpm

RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
    && docker-php-ext-install mcrypt pdo_mysql

WORKDIR /var/www

When i run the "docker-compose up" after running the "composer install".

I get below errors.


executor failed running [/bin/sh -c apt-get update && apt-get install -y libmcrypt-dev mariadb-client && docker-php-ext-install mcrypt pdo_mysql]: exit code: 1 ERROR: Service 'app' failed to build

Any idea on how to fix this?

Note: I already tried replacing mariadb-client with mysql-client and default-my-client, still the same issue.

1 Answer 1

1

You have a couple problems here, which is why switching to mariadb didn't work on its own.

One way to make it more clear what the problem is, is to bash into a container created from your base image and run the commands manually.

docker run -it php:7-fpm bash

From there if you run each install individually you'll see where you are failing:

# apt-get install -y mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql-client

Either add a repo that provides mysql, or use mariadb.

# docker-php-ext-install mcrypt
error: /usr/src/php/ext/mcrypt does not exist

mcrypt was removed in php 7.2 so you'll need to use pecl to install it, if you really need it.

Unless you're running a very old version of Laravel, you shouldn't need mcrypt.

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.