Mysql container only with status "Restarting"

Hi, I’m Danilo Martins, I’m working with Docker and I have a Mysql database container, I installed it as docker-composer below but my mysql container is only in Restarting mode. I do not know what to do anymore …

version: ‘2’
services:
db:
image: mysql:5.7
volumes:
- “./data:/var/lib/mysql”
restart: always
ports:
- “8081:3306”
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: mydb
MYSQL_USER: root
MYSQL_PASSWORD: root

web:
    volumes:
        - "./src:/var/www/html"
    depends_on:
        - db
    image: danilomartinspacs/devback
    links:
        - db
    ports:
        - "8000:80"
    restart: always

Hi Danilo Martins,

I guess that there is a problem inside your DB container, that makes the mysql process stop. That causes the container to shutdown. Because of ‘restart: always’, it always tries to restart again.

To find the problem you can:
docker logs -f <db_container_name>
This will give you the logs of this container, probably including what mysql is doing and its errors. If you need help interpreting the logs, you could post them here. I hope I can come back to your problem.

yes, or run docker-compose up

so without the -d

which will throw errors directly at you

Hi, i am also facing. Please let me know how you resolved this issue.

I am also facing…

" standard_init_linux.go:228: exec user process caused: exec format error "

how to fix it?

Hello friends, I had the same problem.
I’ll share how I solved it:

As I am using docker-compose , I ran the command in the terminal:
docker-compose up
And I observed the log that returned the following error:

dashboard-mysql | error: database is uninitialized and password option is not specified
dashboard-mysql | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

And I found that the database password was missing. I added this information and made a new build. And now it’s working.