0

I am not able to run my Django and MySql application with docker-compose up command. I don't know how exactly to configure the host parameter of database from Django project settings. Earlier while configuring the same for other application it worked well. I don't understand what exactly went wrong this time.

settings.py

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'eitan_database', 'USER': 'root', 'PASSWORD': 'root', 'HOST': 'mysql_db', 'PORT': 3306, } } 

docker-compose.yaml

version: "3" services: eitan-application: restart: always build: context: . ports: - "8000:8000" volumes: - ./app:/app command: > sh -c "python manage.py migrate && python manage.py makemigrations && python manage.py runserver 0.0.0.0:8000" depends_on: - mysql_db mysql_db: image: mysql:5.7 volumes: - "./mysql:/var/lib/mysql" ports: - "8080:3306" restart: always environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_DATABASE=eitan_database - MYSQL_USER=root - MYSQL_PASSWORD=root 

Dockerfile

FROM python:3.7-slim ENV PYTHONUNBUFFERED 1 RUN apt-get update RUN apt-get install python3-dev default-libmysqlclient-dev gcc -y COPY ./requirements.txt /requirements.txt RUN pip install -r /requirements.txt RUN mkdir /app WORKDIR /app COPY ./app /app 

Stack Trace

Traceback (most recent call last): eitan-application_1 | File "manage.py", line 21, in <module> eitan-application_1 | main() eitan-application_1 | File "manage.py", line 17, in main eitan-application_1 | execute_from_command_line(sys.argv) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line eitan-application_1 | utility.execute() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute eitan-application_1 | self.fetch_command(subcommand).run_from_argv(self.argv) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv eitan-application_1 | self.execute(*args, **cmd_options) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 366, in execute eitan-application_1 | self.check() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 395, in check eitan-application_1 | include_deployment_checks=include_deployment_checks, eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/migrate.py", line 63, in _run_checks eitan-application_1 | issues = run_checks(tags=[Tags.database]) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks eitan-application_1 | new_errors = check(app_configs=app_configs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/core/checks/database.py", line 10, in check_database_backends eitan-application_1 | issues.extend(conn.validation.check(**kwargs)) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 9, in check eitan-application_1 | issues.extend(self._check_sql_mode(**kwargs)) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/mysql/validation.py", line 13, in _check_sql_mode eitan-application_1 | with self.connection.cursor() as cursor: eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner eitan-application_1 | return func(*args, **kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 260, in cursor eitan-application_1 | return self._cursor() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 236, in _cursor eitan-application_1 | self.ensure_connection() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner eitan-application_1 | return func(*args, **kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection eitan-application_1 | self.connect() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__ eitan-application_1 | raise dj_exc_value.with_traceback(traceback) from exc_value eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 220, in ensure_connection eitan-application_1 | self.connect() eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner eitan-application_1 | return func(*args, **kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/base/base.py", line 197, in connect eitan-application_1 | self.connection = self.get_new_connection(conn_params) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/utils/asyncio.py", line 24, in inner eitan-application_1 | return func(*args, **kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 233, in get_new_connection eitan-application_1 | return Database.connect(**conn_params) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/MySQLdb/__init__.py", line 84, in Connect eitan-application_1 | return Connection(*args, **kwargs) eitan-application_1 | File "/usr/local/lib/python3.7/site-packages/MySQLdb/connections.py", line 179, in __init__ eitan-application_1 | super(Connection, self).__init__(*args, **kwargs2) eitan-application_1 | django.db.utils.OperationalError: (2005, "Unknown MySQL server host 'mysql_db' (-2)") eitan_mysql_db_1 exited with code 2 

MySql Container Logs

docker-compose logs -f mysql_db

Attaching to eitan_mysql_db_1 mysql_db_1 | 2020-03-03 10:10:10+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started. mysql_db_1 | 2020-03-03 10:10:11+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' mysql_db_1 | 2020-03-03 10:10:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started. mysql_db_1 | 2020-03-03 10:10:11 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). mysql_db_1 | 2020-03-03 10:10:11 0 [Note] mysqld (mysqld 5.6.47) starting as process 1 ... mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Plugin 'FEDERATED' is disabled. mysql_db_1 | mysqld: Table 'mysql.plugin' doesn't exist mysql_db_1 | 2020-03-03 10:10:11 1 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Using atomics to ref count buffer pool pages mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: The InnoDB memory heap is disabled mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Memory barrier is not used mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Compressed tables use zlib 1.2.11 mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Using Linux native AIO mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Using CPU crc32 instructions mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Completed initialization of buffer pool mysql_db_1 | 2020-03-03 10:10:11 1 [Note] InnoDB: Highest supported file format is Barracuda. mysql_db_1 | InnoDB: No valid checkpoint found. mysql_db_1 | InnoDB: If you are attempting downgrade from MySQL 5.7.9 or later, mysql_db_1 | InnoDB: please refer to http://dev.mysql.com/doc/refman/5.6/en/upgrading-downgrading.html mysql_db_1 | InnoDB: If this error appears when you are creating an InnoDB database, mysql_db_1 | InnoDB: the problem may be that during an earlier attempt you managed mysql_db_1 | InnoDB: to create the InnoDB data files, but log file creation failed. mysql_db_1 | InnoDB: If that is the case, please refer to mysql_db_1 | InnoDB: http://dev.mysql.com/doc/refman/5.6/en/error-creating-innodb.html mysql_db_1 | 2020-03-03 10:10:11 1 [ERROR] Plugin 'InnoDB' init function returned error. mysql_db_1 | 2020-03-03 10:10:11 1 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. mysql_db_1 | 2020-03-03 10:10:11 1 [ERROR] Unknown/unsupported storage engine: InnoDB mysql_db_1 | 2020-03-03 10:10:11 1 [ERROR] Aborting mysql_db_1 | mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Binlog end mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'partition' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_SYS_TABLES' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_FT_CONFIG' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_FT_DELETED' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_METRICS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_CMPMEM' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_CMP_RESET' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_CMP' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_LOCKS' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'INNODB_TRX' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'BLACKHOLE' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'ARCHIVE' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'MRG_MYISAM' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'MyISAM' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'MEMORY' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'CSV' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'sha256_password' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'mysql_old_password' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'mysql_native_password' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] Shutting down plugin 'binlog' mysql_db_1 | 2020-03-03 10:10:11 1 [Note] mysqld: Shutdown complete mysql_db_1 | mysql_db_1 | 2020-03-03 10:10:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started. mysql_db_1 | 2020-03-03 10:10:14+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' mysql_db_1 | 2020-03-03 10:10:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.47-1debian9 started. mysql_db_1 | 2020-03-03 10:10:14 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). mysql_db_1 | 2020-03-03 10:10:14 0 [Note] mysqld (mysqld 5.6.47) starting as process 1 ... mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Plugin 'FEDERATED' is disabled. mysql_db_1 | mysqld: Table 'mysql.plugin' doesn't exist mysql_db_1 | 2020-03-03 10:10:14 1 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Using atomics to ref count buffer pool pages mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: The InnoDB memory heap is disabled mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Memory barrier is not used mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Compressed tables use zlib 1.2.11 mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Using Linux native AIO mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Using CPU crc32 instructions mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Completed initialization of buffer pool mysql_db_1 | 2020-03-03 10:10:14 1 [Note] InnoDB: Highest supported file format is Barracuda. mysql_db_1 | InnoDB: No valid checkpoint found. mysql_db_1 | InnoDB: If you are attempting downgrade from MySQL 5.7.9 or later, mysql_db_1 | InnoDB: please refer to http://dev.mysql.com/doc/refman/5.6/en/upgrading-downgrading.html mysql_db_1 | InnoDB: If this error appears when you are creating an InnoDB database, mysql_db_1 | InnoDB: the problem may be that during an earlier attempt you managed mysql_db_1 | InnoDB: to create the InnoDB data files, but log file creation failed. mysql_db_1 | InnoDB: If that is the case, please refer to mysql_db_1 | InnoDB: http://dev.mysql.com/doc/refman/5.6/en/error-creating-innodb.html mysql_db_1 | 2020-03-03 10:10:14 1 [ERROR] Plugin 'InnoDB' init function returned error. mysql_db_1 | 2020-03-03 10:10:14 1 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. mysql_db_1 | 2020-03-03 10:10:14 1 [ERROR] Unknown/unsupported storage engine: InnoDB mysql_db_1 | 2020-03-03 10:10:14 1 [ERROR] Aborting mysql_db_1 | mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Binlog end mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'partition' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_SYS_TABLES' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_FT_CONFIG' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_FT_DELETED' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_METRICS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_CMPMEM' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_CMP_RESET' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_CMP' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_LOCKS' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'INNODB_TRX' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'BLACKHOLE' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'ARCHIVE' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'MRG_MYISAM' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'MyISAM' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'MEMORY' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'CSV' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'sha256_password' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'mysql_old_password' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'mysql_native_password' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] Shutting down plugin 'binlog' mysql_db_1 | 2020-03-03 10:10:14 1 [Note] mysqld: Shutdown complete mysql_db_1 | mysql_db_1 | 2020-03-03 10:10:17+00:00 [Note] 
5
  • is your db container is up and running ? see what in docker ps Commented Mar 3, 2020 at 9:51
  • no the status of db container is Restarting (2) 6 second ago Commented Mar 3, 2020 at 9:56
  • then show the logs to see the errors: docker logs CONATINER_NAME Commented Mar 3, 2020 at 9:58
  • check docker-compose logs -f mysql_db for more info looks like your mysql container is not up Commented Mar 3, 2020 at 10:00
  • There is something wrong with your db try dropping it and restarting Commented Mar 3, 2020 at 12:25

3 Answers 3

1

On your docker-compose.yaml file you are exposing the database on port 8080 and trying to access it through port 3306 on the setting.py file.

Sign up to request clarification or add additional context in comments.

Comments

1

There are a couple of things wrong with your setup

  1. The error is a MySQL connection error because the service is not listening on port 3306 as you are binding it to port 8080 therefore you need to change your DATABASES dictionary to the following

  2. Your python commands are in the wrong order. You need to run makemigrations prior to migrate. The former creates the migration files, the latter then applies them to the database

Comments

0

In settings.py the HOST parameter name was incorrect.

RUN docker ps

Check for the NAME of image MySql:5.6 and copy it.

Then in your setting.py file update HOST parameter of your database with the NAME of newly create MySql container.

DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'eitan_database', 'USER': 'root', 'PASSWORD': 'root', 'HOST': '' c# name of newly created `mysql:5.6` image container name 'PORT': 3306, } } 

Also, remove ports from service mysql_db which is in your docker-compose file.

ports: - "8080:3306" 

Now RUN

docker-compose up

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.