Docker Community Forums

Share and learn in the Docker community.

My mysql container is refusing the connection

Hi everyone, I am new to docker, I am migrating my laravel project to docker, I am using docker toolbox, I create several containers, among them mysql which is the one that is giving me problems, I recently added volume to mysql to persist my database data (if I remove the volume it works perfect), when trying to run the command “docker-compose run --rm artisan migrate” I get the error 2002 connection refused, and if i try to login from heidi it won’t let me in either, it is probably a silly mistake but i have been with this problem for quite a while. I would greatly appreciate your help, I have the next configuration for mysql in my docker-compose.yml file:

mysql:
image: mysql:5.7.29
container_name: mysql
restart: unless-stopped
tty: true
ports:
  - "3306:3306"
volumes:
  - ./mysql:/var/lib/mysql
environment:
  MYSQL_DATABASE: my_name_db
  MYSQL_USER: user1
  MYSQL_PASSWORD: secret
  MYSQL_ROOT_PASSWORD: secret
  SERVICE_TAGS: dev
  SERVICE_NAME: mysql
networks:
  - laravel