Veshraj Joshi
Veshraj Joshi

Reputation: 3579

docker mysql image is not working in M1 Pro while its working fine in ubuntu

I do have the following content on docker-compose.yml

version: '3.9'

services:
    nginx:
        build:
            context: "./docker/build/nginx"
            dockerfile: Dockerfile
        ports:
            - "${APP_PORT:-9090}:80"
        volumes:
            - "./docker/build/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf"
            - ".:/var/www/html"
        links:
            - app
        networks:
            - php_mysql_network
    app:
        build:
            context: "./docker/build/php/8.2"
            target: app_dev
        environment:
            MYSQL_HOST: db
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 1
            XDEBUG_MODE: "${XDEBUG_MODE:-off}"
        extra_hosts:
            - host.docker.internal:host-gateway
        volumes:
            - ".:/var/www/html"
            - ./docker/build/php/xdebug/conf.d/xdebug.ini:/usr/php/conf.d/xdebug.ini:ro
        depends_on:
            - mysql
        networks:
            - php_mysql_network
    mysql:
        image: 'mysql/mysql-server:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ROOT_HOST: "%"
            MYSQL_DATABASE: '${DB_DATABASE}'
            MYSQL_USER: '${DB_USERNAME}'
            MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 1
        volumes:
            - './docker/build/mysql8:/var/lib/mysql'
        networks:
            - php_mysql_network

networks:
    php_mysql_network:
        driver: bridge

Which is working fine in ubuntu 20.04 and 22.04 OS. I have been using a similar structure since March 2021 over ubuntu. Unfortunately, with this docker-compose.yml M1 Pro is unable to run the MySQL instance using docker.

For the first time, I got the following error when I ran the docker compose up command enter image description here

For the second time, I got the following error when I ran the docker compose up in

What I am doing wrong here? As per error it seems like mysql is running twice

Upvotes: 0

Views: 180

Answers (1)

Anmup Giri
Anmup Giri

Reputation: 170

It might be support issue for M1 processors. Some images are not compatible to arm64v8. Try using compatible images for mysql

https://hub.docker.com/r/arm64v8/mysql/tags

Upvotes: 1

Related Questions