yobasystems / alpine-mariadb

MariaDB running on Alpine Linux [Docker]
https://hub.docker.com/r/yobasystems/alpine-mariadb/
242 stars 72 forks source link

alpine-mariadb with python on Raspberry Pi 2 #53

Closed emmaparker96 closed 3 years ago

emmaparker96 commented 3 years ago

Currently, I am in the process of implementing two Docker containers on the Raspberry Pi 2 - one for a Python and one for a mariadb database. The Python script is supposed to retrieve data from the database.

My .yml file to build the docker containers on Windows x64 :

    version: "3.9"
    services:
      app:
        build: ./app
        links:
          - db
        restart: on-failure

      db:
        image: yobasystems/alpine:3.13.5-armhf
        ports:
          - "3306:3306"
        environment:
          MYSQL_ROOT_PASSWORD: password
          MYSQL_DATABASE: mydb
        volumes:
          - ./db:/docker-entrypoint-initdb.d/:ro

Essential part of Python script:

    import mysql.connector

    mydb = mysql.connector.connect(
      host="db",
      user="root",
      password="password",
      database="mydb"
    )

I execute the commands on Windows x64:

    docker-compose up
    docker save -o mydb.tar mariadb_db_1
    docker save -o mypython.tar python_app_2

Then on the Raspberry Pi 2, I execute the commands:

    docker load -i mydb.tar
    docker load -i mypython.tar

    docker run -i -t mariadb_db_1
    docker run -i -t python_app_2

When I run mariadb_db_1, I get thrown right into the sh-shell (I don't know if database is running). Then when I run python_app_2 from another shell, I get the following error from the mysql.connector.connect method: Can't connect to MySQL server on '%-.100s:%u' (%s)'

What could be the reason that it does not work under the Raspberry Pi 2? And why do I get thrown into the sh-shell with the database?

dominictayloruk commented 3 years ago

Not sure really what your trying to do.

Not sure how you can build armhf containers in Windows?? or even why you would be building the container when you can just pull the pre-built version. If your running on Raspberry Pis then surely you'd be on a linux distro.

This probably has more to do with your python stuff, maybe ask for help on that image.

dominictayloruk commented 3 years ago

Your image is incorrect

db:
        image: yobasystems/alpine:3.13.5-armhf

Surely that should be

db:
        image: yobasystems/alpine-mariadb:10.5.9