Docker container starts from CLI but not from docker-compose.yml

  confluence, docker, docker-compose, linux, mysql

I have a MySQL docker container running on Linux.
It has a database called confluence populated with some 140 tables.
It starts fine when initiated from CLI like so:

docker run --name mysqlconf -v /local/disk0/confluence/:/data -e MYSQL_ROOT_PASSWORD=XXXXXXX -e MYSQL_ROOT_HOST=% -e character-set-server=utf8 -e collation-server=utf8_bin -v sql_volume:/var/lib/mysql -p 3306:3306 -d rbarak/mysql:CHARACTER-SET-utf8

However, when I try to get the same parameters in a docker-compose.yml,
it fails to start and complains:

2021-06-01T23:42:57.436446Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-06-01T23:42:57.436459Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-06-01T23:42:57.436523Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-06-01T23:42:57.436680Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.25)  MySQL Community Server - GPL.

This is my docker-compose.yml:

version: '3'
services:
  confl-mysql:
    image: rbarak/mysql:CHARACTER-SET-utf8
    container_name: mysqlconf
    restart: always
    volumes:
      - /local/disk0/confluence/:/data
      - sql_volume:/var/lib/mysql
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_HOST=%
      - MYSQL_ROOT_PASSWORD=XXXXXXX
    command: [mysqld, --character-set-server=utf8, --collation-server=utf8_bin]
   
volumes:
  sql_volume:

What am I doing wrong in my docker-compose.yml?

Source: Docker Questions

LEAVE A COMMENT