Mysql container goes into exit(1) immediately after startup in Docker

Asked 2 years ago, Updated 2 years ago, 88 views

Prerequisites

I'm trying to launch a laravel environment with docker-compose, but the container in mysql will be exited(1) as soon as it starts.

It started up until about 3 days ago, but suddenly it didn't work properly.

What do you want to do

  • I want to launch mysql container with docker-compose

Problems/Error Messages you are experiencing

  • docker-compose up-d and only mysql containers immediately become exited(1)
 ddocker-compositions
NAME COMMAND SERVICE STATUS PORTS
mysql_fargate "docker-entrypoint.s…"db expired(1)
nginx_fargate"/docker-entrypoint...."web running 0.0.0.0:80->80/tcp
php_fargate "docker-php-entrypoi..." app running 9000/tcp
  • docker-compose logs db displays the following error:
 mysql_fargate | chown:changing ownership of './proc/94/task/96': Operation not permitted
mysql_fargate | chown:cannot access'./proc/94/task/96/fd/4'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/task/96/fd/5'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/task/96/fd/6'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/task/96/fd/7'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/task/96/fd/8'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fd/9'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fdinfo/4'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fdinfo/5'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fdinfo/6'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fdinfo/7'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fdinfo/8'—No such file or directory
mysql_fargate|chown:cannot access'./proc/94/task/96/fdinfo/9'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fd/4'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fd/5'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fd/6'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fd/7'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fdinfo/4'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fdinfo/5'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fdinfo/6'—No such file or directory
mysql_fargate | chown:cannot access'./proc/94/fdinfo/7'—No such file or directory

I would appreciate it if you could let me know if you have any knowledge of the authority.

Source Codes Affected

  • mysql/Dockerfile↓
 FROM -- platform=linux/amd64mysql: 8.0

COPY./docker/mysql/my.cnf/etc/my.cnf
  • php/Dockerfile↓
 FROM php: 8.0-fpm

# COPY php.ini
COPY./docker/php/php.ini/usr/local/etc/php/php.ini

# Composer install
COPY --from=composer: 2.0/usr/bin/composer/usr/bin/composer

# install Node.js
COPY --from=node: lts/usr/local/bin/usr/local/bin
COPY --from=node: lts/usr/local/lib/usr/local/lib

RUN apt-get update &&\
    apt-get-y install\
    git\
    zip\
    unzip\
    vim\
    &docker-php-ext-install pdo_mysql bcmath

WORKDIR/var/www/html
  • nginx/Dockerfile↓
 FROM nginx: 1.18-alpine

ENV TZ Asia/Tokyo

# nginx config file
COPY./docker/nginx/*.conf/etc/nginx/conf.d/

WORKDIR/var/www/html
  • docker-compose.yml↓
version: '3.3'

services:
  app:
    build:
      context:.
      dockerfile:./docker/php/Dockerfile
    container_name —php_fargate
    volumes:
      - ./src/:/var/www/html
    environment:
      - DB_CONNECTION=mysql
      - DB_HOST=db
      - DB_PORT=3306
      - DB_DATABASE=${DB_NAME}
      - DB_USERNAME=${DB_USER}
      - DB_PASSWORD=${DB_PASSWORD}
      - "TZ=Asia/Tokyo"

  web:
    build:
      context:.
      dockerfile:./docker/nginx/Dockerfile
    container_name —nginx_fargate
    ports:
      - ${WEB_PORT}:80
    depend_on:
      - app
    volumes:
      - ./src/:/var/www/html

  db:
    build:
      context:.
      dockerfile:./docker/mysql/Dockerfile
    container_name —mysql_fargate
    ports:
      - ${DB_PORT}: 3306
    environment:
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      TZ: 'Asia/Tokyo'
    volumes:
      - mysql-volume: /var/lib/mysql

volumes:
  mysql-volume:

Tried

  • Delete docker system prune-a or volume
  • deleting docker image, docker container
  • Change port
  • increase memory in docker desktop
  • I tried other codes, but they didn't start well

Supplementary information (for example, FW/Tool Version)

  • Apple M1 Pro
  • Lavel Framework 9.26.1
  • node v16.17.0

mysql docker docker-compose docker-for-mac

2022-09-29 21:38

1 Answers

Comment out the line below from mysql/Dockerfile to make my.cnf configuration happen in a different way.

COPY./docker/mysql/my.cnf/etc/my.cnf

Maybe there was a change in the host OS configuration, but my.cnf is no longer authorized to COPY, so I went to run chown to get it (although I can't).


2022-09-29 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.