I
I
idin2017-10-03 00:09:27
linux
idin, 2017-10-03 00:09:27

Docker_composer, how to connect to a mysql database running in a container?

there is this docker-composer.yml :

version: '3.3'

services:

    db:
      image: mysql
      ports:
        - 3306:3306
      volumes:                         #  оговорюсь сразу ,убрать запись/оставить
        - ./db:/var/lib/mysql      #  не как не влияет на ошибку
      restart: always
      environment:
        MYSQL_DATABASE: db_ferst
        MYSQL_USER: root
        MYSQL_PASSWORD: root
        MYSQL_ROOT_PASSWORD: root


    adminer:
        image: adminer
        restart: always
        ports:
            - 8080:8080

I start everything with the command: sudo docker-compose up -d
Adminer starts, but MySQL does not.
command : sudo docker-compose ps shows :
21ccfde5a2a4        adminer             "entrypoint.sh doc..."   3 minutes ago       Up 3 minutes                    0.0.0.0:8080->8080/tcp   dockermysql_adminer_1
a402abedb0f6        mysql               "docker-entrypoint..."   3 minutes ago       Restarting (1) 29 seconds ago                            dockermysql_db_1

and the command sudo docker-compose logs db throws a bunch of errors (and this repeats 10 times):
db_1  | Initializing database
db_1  | 2017-10-02T20:18:00.901998Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1  | mysqld: Can't create/write to file '/tmp/ib5L9l18' (Errcode: 13 - Permission denied)
db_1  | 2017-10-02T20:18:00.904876Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 13
db_1  | 2017-10-02T20:18:00.904883Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
db_1  | 2017-10-02T20:18:00.904889Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
db_1  | 2017-10-02T20:18:00.904892Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
db_1  | 2017-10-02T20:18:00.904896Z 0 [ERROR] Failed to initialize plugins.
db_1  | 2017-10-02T20:18:00.904899Z 0 [ERROR] Aborting

and it seems to me that the error is somewhere with access rights.
as a result, when we go to 127.0.0.1:8080, then naturally we don’t go into the admin panel of the database:
59d2aafb975eb393265999.png
Well, I would like to understand why this happens to me, and where I mess up ((.
My goal is to deal with docker and learn how to use it.
Z.Y . thanks in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question