I see multiple solutions for this question but still I am unable to make progress hence posting this question
I have react+django+mysql app and I want to deploy that into docker, but when I am trying to do my sql image is not created, it says db uses and image, skipping.
but I see there was no image created for mysql (it had one but I force deleted, so it can get create new one), I tried solution given here and tried to run below command
docker run mysql -h 127.0.0.1 -P 3306
but it asked me give password, root password etc, what went wrong for me?
below is my logs
PFb my docker-compose.yaml
version: '3.2'
services:
db:
image: mysql:8.0
ports:
- '3302:3306'
environment:
MYSQL_DATABASE: 'motor_vehicle_collision'
MYSQL_USER: 'creditshelf_user'
MYSQL_PASSWORD: '12345678'
MYSQL_ROOT_PASSWORD: '12345678'
networks:
- db-net
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/motor_vehicle_crash
ports:
- "5000:8000"
depends_on:
- db
frontend:
restart: always
command: npm start
container_name: front
build:
context: ../../../react code/collision-UI/collision-info
dockerfile: Dockerfile
ports:
- "3000:3000"
stdin_open: true
depends_on:
- web
networks:
- db-net
networks:
db-net:
driver: bridge
below is my python project Dockerfile
FROM python:3.8
ENV PYTHONUNBUFFERED 1
RUN mkdir /collision_bike_info
WORKDIR /collision_bike_info
ADD requirements.txt /collision_bike_info/
RUN pip install -r requirements.txt
ADD . /collision_bike_info/
below my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'motor_vehicle_collision',
'USER': 'creditshelf_user',
'PASSWORD': '12345678',
'HOST': 'localhost',
'PORT' : '3306'
# 'NAME': BASE_DIR / 'db.sqlite3',
}
}
Solution:
below answer worked for me but however I ran into different problem now my sql says
(1045, 'Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory')
from google I got to know it is due to new mysql version (8.0 onwards) so either I need to downgrade my sql image or I need to change password policy for my user, how do I change policy this user of my sql docker?
and if I downgrade it says unkow host db f0r mysql, what should I do?