0

When run docker-compose up, django container says

django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)”)

And db container says

Version: '5.7.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)

It seems like they cannot connect to each other because of different socket location. I want to know if I can change socket file location.

1
  • what is the django database config and what is the mysql service name in compose? Commented Feb 6, 2020 at 6:28

1 Answer 1

0

If you run the app and the db in different containers they can't connect to each other by sockets by default. You have to use kind of db connection string with host and port or you have to share somehow the socket file between this two containers. As for me the first options is easier.

Probably this is what you're looking for. In this case db host will be a service name from docker-compose.yml.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.