Score:0

Docker container communicating with mariadb crashes on Got an error reading communications packet

cn flag

I have Rails app in docker and also mariadb docker image.

But it fails during connection on

2021-11-05 8:27:49 3 [Warning] Aborted connection 3 to db: 'development' user: 'root' host: '172.18.0.4' (Got an error reading communication packets)``

My dockerfile is

FROM ruby:2.6.5

RUN apt-get update; apt-get install -y build-essential nodejs npm vim htop
RUN npm install --global yarn

RUN mkdir -p /app
WORKDIR /app

ENV BUNDLER_VERSION=2.1.4

COPY Gemfile Gemfile.lock /app/

RUN gem install bundler:2.1.4
RUN bundle install --jobs 20 --retry 5
RUN yarn install --silent --no-progress --no-audit --no-optional --check-files

#RUN bundle exec rake db:migrate

# Copy the main application.
COPY . ./

RUN rm -f /app/tmp/pids/server.pid

EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]

Mariadb dockerfile is (note that is for my localhost development so no passwords required)

FROM mariadb


RUN apt-get update; apt-get install -y build-essential vim htop

ENV MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=yes
ENV MARIADB_DATABASE=development
ENV MARIADB_USER=root

COPY ./schema.sql /docker-entrypoint-initdb.d/a-schema.sql
COPY ./data.sql /docker-entrypoint-initdb.d/b-data.sql


And composer file

services:
  app:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - .:/app
    ports:
      - "3000:3000"
    links:
      - mariadb
    environment:
      WEBPACKER_DEV_SERVER_HOST: webpack
      RAILS_ENV: development
      RACK_ENV: development
      DATABASE: development
      DB_USERNAME: root
      DB_HOST: mariadb
      LOCALISATION: cs
    depends_on:
      - webpack

  mariadb:
    build:
      context: .
      dockerfile: Dockerfile.mariadb
    restart: on-failure
    volumes:
      - ./mariadb:/var/lib/mysql

  webpack:
    build: .
    command: ./bin/webpack-dev-server
    #volumes:
    #  - .:/app
    ports:
      - '3035:3035'
    environment:
      NODE_ENV: development
      RAILS_ENV: development
      WEBPACKER_DEV_SERVER_HOST: 0.0.0.0

when I try to connect from app container to database using mysql_client it works, also app starts and checks for migrations but in next selects falls down.

Please any suggestions? It drives me mad

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.