MySQL on Docker failing to start

Currently reading
MySQL on Docker failing to start

4
0
NAS
DS218+
Operating system
  1. Linux
  2. Windows
Mobile operating system
  1. Android
When trying to run MySQL on Docker (on my Synology server), I have specified the stack.yml location like this:

stack_yml.jpg


Its contents are:

# Use root/example as user/password credentials
version: '3.1'

services:

db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: myPass123

adminer:
image: adminer
restart: always
ports:
- 8081:8080

I am able to start the Docker, but after a short time it stops. The logs show:

You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD

Am I referencing the file incorrectly, are the contents of the file incorrect, or am I doing something else wrong?

I am using the official MySQL Docker image I'm using is Docker Hub version 5.7.32
 
Why would you mount a docker-compose.yml using a volume?
I sense a lot of potential for confusion here...

Also this is not a valid docker-compose.yml, as all the required indentions to make it a valid docker-compose.yml are missing....

Do you mind to elaborate on what you try to do, and what actions you took to try to make it run? You initial post does not make much sense...
 
It's my first time using Docker, so I might be confused :)

I want to set up 2 Dockers:
1) PrestaShop (Docker Hub)
2) MySQL (Docker Hub)

I'm setting up the MySQL Docker first.

The instructions say:

Example stack.yml for mysql:

# Use root/example as user/password credentials
version: '3.1'

services:

db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: example

adminer:
image: adminer
restart: always
ports:
- 8080:8080

So to me it looks like the configuration (including the root password) should be held within a configuration file stack.yml.

I'm thinking the issue is with Mount Path I've defined...

All I've done so far is download the image and launch it with the stack,yml file and mapping I detailed in my original post.
 
Did you create a docker-compose.yml file on your NAS, connect via SSH to a shell terminal, become root, change to the folder where your docker-compose.yml is stored and execute docker-compose up -d?

If this is not the case, please write a detailed description of your steps, preferably with screenshots if you used the UI.. if you used the shell, the exact commands.

Your docker-compose.yml still lacks all required indentions. The compose declarations you pasted are basicly invalid.
 
I did it all via the Synology Docker GUI. I've documented everything here Installing MySQL 5_7_32 Docker on Synology.docx

The stack.yml does have the required indentation, it just didn't format properly on this website, I have included it in my document. I wrote the file in Windows Notepad, copied it from Windows to a location on the Synology file system, then used Synology File Station to move it to the required location under /docker.

I still think the issue with the 'Mount path' setting (within the 'Volume' configuration), but it might also be something else I've done wrong 😊
 
Now I get where you confusion commes from:
The headline of what you copied and call stack.yml is intended to be used with these command line tools:

... via docker stack deploy or docker-compose


Synology provides docker-compose on the command line! You either use the docker-compose approach with the docker-compose.yml declaration OR the ui. Both methods do not mix and mingle! Though, you will be able to manage containers, created with docker-compose in Syno's docker ui.

So bacily you did mount an unrelated file to a location in the conatiner where nothing uses it. Basicly you started the mysql container without any parameters and mapped volumes. Trust me, this is not what you want.

All -e KEY=value params from the dockerhub description translate to an entry in the "Environment" tab, where the key (left hand side before the = character) needs to be entered in "variable" and the value (right hand side after the = character) in "value". Write the KEY exactly as written in the description, only modify the content of the value (unless the description points out why not)

All -v /host/path:/container/path params from the dockerhub description translate to an entry in the "Volume" tab, where the /host/path (left hand side before the : character) can be picked using the buttons "Add File" (will map single file from host to container) and "Add Folder" (will map a folder from host to container). You are free to select what file or folder you want to map, its completly up to you. Write the /container/path into "Mount Path" exactly like written in the description (uness you know exactly why you want/need it differently).

If you map the -e and -v params from the description to the Syno Docker UI. You should be good. Though one more thing: you will need to establish a link in the "Links" tab on the PrestaShop container to link it with the Mysql Container. This wouldn't be necessary when docker-compose and the yml file approach would be used.
 
Hi - i'm running into similar issues trying to get a mysql container working via docker-compose. It seems so simple but i can't get it working - does anyone know a good guide for doing this?

My issue is that the mysql "db" container keeps restarting. When i look at the log it says "db exited with code 1" which implies permissions however i have set up read/write access for the user.

My docker-compose file is (where 1234 is the PUID/PGID of the user with read/write access):




Code:
version: '3.6'

services:

  db:
    image: mysql
    container_name: db
    cap_add:
      - NET_ADMIN
    #command: --default-authentication-plugin=mysql_native_password
    restart: always
    network_mode: bridge
    volumes:
    - /volume1/MySQL/data:/var/lib/mysql
    environment:
    - PUID=1234
    - PGID=1234
    - TZ=Europe/London
    - MYSQL_ROOT_PASSWORD=rootpassword
    - MYSQL_DATABASE=db
    - MYSQL_USER=user
    - MYSQL_PASSWORD=password
 
Code:
ash-4.3# stat volume1/MySQL/
  File: ‘volume1/MySQL/’
  Size: 76              Blocks: 0          IO Block: 4096   directory
Device: c5h/197d        Inode: 256         Links: 1
Access: (0000/d---------)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2021-07-29 00:03:08.819654818 +0100
Modify: 2021-07-27 08:08:01.079644219 +0100
Change: 2021-07-28 23:43:47.844775994 +0100
Birth: -

Above is the output. I tried to create a new user with permissions to the folder and updated the docker-compose file but it didn't change anything. Appreciate the help.
 
At least this was the original problem: a simple unix file permission and owner problem.
Docker container do not care about Syno-ACLs. You need to sort out the unix file permissions and the ownership of course.

This should have fixed it:
Code:
chown 1234:1234 -R /volume1/mySQL
chmod 770 -R /volume1/mSQL

Followed by a docker-compose up -d in the folder where you compose file is located.
 
Thanks that got the container working.

For my own understanding, why doesn't docker follow the synology ACLs? I have set up multiple containers and thought i just managed access for each user in the DSM Shared Folder permissions section.

Also from looking at the synology permissions, the above command seems to have created advanced permissions? Or has it done more as well.

Appreciate the help getting this solved!
 
Last edited:
For my own understanding, why doesn't docker follow the synology ACLs? I have set up multiple containers and thought i just managed access for each user in the DSM Shared Folder permissions section.
That's a brilliant question: you should raise a feature request to Synology. Since they already use a patched version of the docker engine, they could at least patch it to fully support the Syno-ACLs. For the bind-volumes they would need a trickery to "hide" or translate the Syno-ACLs to normal unix file permissions and ownership. As this would be pretty messy, I am quite sure this is why they didn't touched it.

Vanilla docker does not know about Syno ACLs and simply ignores them. The containers you run know nothing about Syno ACLs - they just get a host folder "binded" into a container folder and therefore need so support the same mechnism that Synology uses outside the container inside the container.... This is why hidding/translating would be required :)

Also from looking at the synology permissions, the above command seems to have created advanced permissions? Or has it done more as well.
The command did not remove the "Syno ACL" attributes. It just modified unix filesystem permissions and ownership.

It's always the same: Synology provides the magic of simplicity. Though, everyone know that magic always commes with a price :) Whenever you need more than the magic provides, things typicaly tend to require workarounds outside the ui...

Actualy what would make much sense is to actualy set the expected UID:PID per Container and then let the Docker UI align Folder permissions (of course only activetable per volume). Furthermore, they could provide an option to set the expected UID:PID when starting the container (this must be optional to not break containers like all the linuxserver.io containers). While implenting that, they could add checkboxes to the ui to bind files required by some containers: /etc/passwd (e.g. required by postgres, if you set the container uid:gid), /etc/timezone (which is /etc/TZ on Syno) and /etc/localtime.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

  • Solved
If you are still interested in learning it: If you know how to write bash scripts, it should be possible...
Replies
5
Views
911
I can’t find any option to restore just the settings. 1710356648 Phew, managed to fix it. Within the...
Replies
4
Views
403
Good to hear. Deluge has not been updated for almost two years now as an app, nevertheless. But it gives...
Replies
12
Views
979
  • Question
Open an issue on that GitHub page. The developers will be glad to assist. OP has posted two threads on...
Replies
5
Views
966
I'm happy with email notifications but in v0.3.3 of dockcheck the author added apprise notifications...
Replies
4
Views
1,046
I am also trying to setup a Z-wave USB dongle and am getting stuck after following the same steps as...
Replies
1
Views
1,037
How did you create the Portainer container in first place? As in exact docker run commands or in case...
Replies
7
Views
1,244

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Back
Top