Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker can't accesso to mysql #664

Closed
khalld opened this issue Apr 24, 2020 · 1 comment
Closed

docker can't accesso to mysql #664

khalld opened this issue Apr 24, 2020 · 1 comment
Labels
question Usability question, not directly related to an error with the image

Comments

@khalld
Copy link

khalld commented Apr 24, 2020

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.

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Apr 24, 2020
@wglambert
Copy link

Using a named volume should work, you'd probably also find similar issues over at https://github.com/docker/for-mac/issues

There's also a number of solutions in #95:

MariaDB/mariadb-docker#95 (comment)

Essentially, the best solution is to put /var/lib/mysql in a volume on your Docker VM (managed via docker volume xyz commands) instead of trying to share those files directly all the way back to your Mac or Windows host filesystem.

MariaDB/mariadb-docker#95 (comment)

Yeah, just use a named volume and connect it to more than one container.

MariaDB/mariadb-docker#95 (comment)

using a named volume is basically the only option to keep the database files when running MariaDB on Docker for Windows since the host-shared folder presented to the container does not behave in a standard way.

MariaDB/mariadb-docker#95 (comment)

We recently added #168 which should make sharing a directory from a windows host possible. Try the following (I don't have a host with Docker for Windows at the moment, but it worked when I last checked):

$ # also updated to specify a version of mariadb so that things don't break when latest becomes 10.4
$ docker run --name mariadb -d -v D:\Projects\docker\docker-qub:/var/lib/mysql -e MYSQL_USER=user -e MYSQL_PASSWORD=password -e MYSQL_DATABASE=address -e >MYSQL_ROOT_PASSWORD=password mariadb:10.3 --innodb-flush-method=fsync

For future users that are using docker-compose it would be adding --innodb-flush-method=fsync to the command.


Going to close with what was said in that thread
MariaDB/mariadb-docker#95 (comment)

Docker and MariaDB work fine together; the bit that doesn't work is the custom filesystem employed by Docker for Windows and Docker for Mac for sharing files across the VM boundary, which is not all that surprising for a database, which often use features like mmap for performance but thus also require support from the underlying filesystem. There are many reports of similar issues with vboxsf, for example.

MariaDB/mariadb-docker#95 (comment)

Any fixes would have to happen either in Docker's shared filesystem or in MariaDB itself (not something we can really fix in this Docker image), so I'd recommend checking their respective upstream bugtrackers for any discussion of fixing the problem.

If you still need some help try the Docker Community Forums, Docker Community Slack, or Stack Overflow. Since these repos aren't really a user-help forum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

2 participants