Last times I often get error when using MySQL via Docker Compose:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
read unix @->/var/run/docker.sock: read: connection reset by peer
Exited with code 1
Part of my config:
version: 2
jobs:
build:
machine: true
steps:
- checkout
- run:
name: Install Docker Compose
command: |
curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
chmod +x ~/docker-compose
mv ~/docker-compose /usr/local/bin/docker-compose
- run:
name: Running Docker containers
command: docker-compose up -d
- run:
name: Import test database and run migrations
command: docker exec -i database mysql -u root -ppass --database=name < dump.sql
I have more containers but they work good, only problem with MySQL when I try to import database.
First time this error appeared 3-4 weeks ago, maybe more. Before everything worked fine, and now it works fine, but sometimes I get this error, and I need to rebuild 2-3 times and this error should disappear.
Part of my docker-compose.yml:
version: "2"
networks:
app-tier:
driver: bridge
services:
database:
container_name: database
image: "mariadb:10.2"
phpfpm:
container_name: php-fpm
depends_on:
- database
image: "php:7.1"
networks:
- app-tier