Edit mysql ini in container

Question:

I'm using docker to generate a LAMP.
My yml looks like this:

    web:
     image: tutum/apache-php
     ports:
     - "80:80"
     links:
     - db
     volumes:
     - $PWD:/app

    db:
     image: mysql
     environment:
     - MYSQL_ROOT_PASSWORD= my-secret-pw
     - MYSQL_DATABASE= lamp
     - MYSQL_USER= lamp_user
     - MYSQL_PASSWORD= lamp_pass
     ports:
     - "3306:3306"

When trying to access mysql through another machine, it's giving the following error in the workbench:

Authentication plugin 'caching_sha2_password' cannot be loaded

I saw a crowd saying that I have to edit my.ini and edit the following line with this value:

[mysqld] default_authentication_plugin=mysql_native_password

But I don't know how to edit my.ini .

Am I following the correct solution? If so, how do I edit the file in question?

Answer:

Apparently by defining the version to use mysql, and not leaving the latest , it solved my problem.

In the yml below note that I set mysql version to 5.6.
As a bonus, I added restart: always to automatically restart both containers

        web:
         image: tutum/apache-php
         ports:
         - "80:80"
         links:
         - db
         volumes:
         - $PWD:/app
         restart: always

        db:
         image: mysql:5.6
         environment:
         - MYSQL_ROOT_PASSWORD= my-secret-pw
         - MYSQL_DATABASE= lamp
         - MYSQL_USER= lamp_user
         - MYSQL_PASSWORD= lamp_pass
         ports:
         - "3306:3306"
         restart: always
Scroll to Top