Skip to content

docker can't accesso to mysql #664

Closed
@khalld

Description

@khalld

i'm trying till 3 days to create a db from docker compose.
I already done the procedure on Ubuntu 18.04 LTS but on OSX catalina i'm having a some troubles. It is possibile because i'm using docker desktop? but last time i made the installation i didn't have this troubles

version: "3.2" 

services:
  view-mongodb:
    image: xxxx/view-mongodb:3.6
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.labels.db == true
    volumes:
      #- /opt/mongodb-data:/data/db
      - /Users/danilo/configurazione-view-locale/maria-db-data:/data/db
    networks:
      - view-network
    ports:
      - "27017:27017" 
    logging:
      driver: "json-file"
      options:
        max-size: "50M"
        max-file: "10"

  view-mariadb:
    image: xxxxx/view-mariadb:10.2
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.labels.db == true
    volumes:
      #- /opt/mariadb-data:/var/lib/mysql
      - /Users/danilo/configurazione-view-locale/maria-db-data:/var/lib/mysql
    environment:
       - MYSQL_ROOT_PASSWORD=/run/secrets/VIEW_MYSQL_ROOT_PWD
    secrets:
       - VIEW_MYSQL_ROOT_PWD
       - VIEW_DB_PWD
    networks:
      - view-network
    ports:
      - "3306:3306" 
    logging:
      driver: "json-file"
      options:
        max-size: "50M"
        max-file: "10"

networks:
  view-network:
    driver: overlay
    ipam:
      driver: default
      config:
        - subnet: 10.10.10.0/24

secrets:
  VIEW_MYSQL_ROOT_PWD:
    external: true
  VIEW_DB_PWD:
    external: true

first of all if i want to mount the volume on /opt/mongodb-data docker can't write the file there, i already try to give permission using chown 777 but it's not working.
So i changed the path (works) and when i have to exec the container using

docker exec -it <ID container> sh /opt/init.sh 

i have this error

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I opened using sh the init.sh and verify that the path of the secret works (i used also the direct message)

there are the secret that i used, maybe i understand something but, i repeat, the process works on Ubuntu 18.04 LTS

$ echo "view-mariadb" | docker secret create VIEW_DB_HOST -$ echo "3306" | docker secret create VIEW_DB_PORT -$ echo "view" | docker secret create VIEW_DB_VIEW -$ echo "webstudio" | docker secret create VIEW_DB_DOK -$ echo "view" | docker secret create VIEW_DB_USER -

echo "password" | docker secret create VIEW_MYSQL_ROOT_PWD -
echo "password" | docker secret create VIEW_DB_PWD -

Someone can help? (I censored the name of the images because they own my company) also, if i want to try to don't use the password for skip the problem, what i have to do ? And, if want to put the variables static, like, on the environment

MYSQL_ROOT_PASSWORD: example
i have to use the secret too?

Thanks so much for who is going to answer, i'm getting crazy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionUsability question, not directly related to an error with the image

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions