Starting mysql on container start

Currently reading
Starting mysql on container start

3
2
NAS
DS1621+
Operating system
  1. Windows
Mobile operating system
  1. Android
Hello, new to docker and trying a little project.

I have setup a simple Ubuntu 22.04 container and using bash i have installed all the services and features i need, mostly MySQL 8.0 and a few networking features. I also setup the mysql databases (in a mounted folder on the NAS), user accounts, and set the passwords for the accounts.

I then used 'docker commit' to save the upgraded container as a new image. Everything works, and if I use the image to make a container and boot that container, i can use the attached terminal to run 'service mysql start' and it will run perfectly.

But I would like mysql to start on its own unattended. And I am having real trouble googling how to make this happen.

I have tried setting the command to = --default-authentication-plugin=mysql_native_password
and setting a variable MYSQL_ROOT_PASSWORD with the root users SQL password.

DSM is 7.2 and Container Manager is 20.10.23
 
Solution
If you are still interested in learning it: If you know how to write bash scripts, it should be possible to write a Dockerfile. After all the RUN instructions are just shell commands. The tricky part is usually the entrypoint script, depending on how much "magic" you want to apply before you start the main process.

It is always helpful to take a look at how others solved specific challenges. You can find the Dockerfile and all files it copies into the image during build of most images on Github, Gitlab or other public git hosting platforms. Sometimes you can find the link to the git repo in the Docker Hub description.

The git project to build the mysql image can be found here: GitHub - docker-library/mysql: Docker Official Image...
This sounds like an Ubuntu question to set a service to auto start, to which using this web search (of your choice) seems to get quite a few results: ubuntu auto start service

An alternative question: why not just run the official MySQL image in its own container and link to it from your container? I do this with Postgres and assume it’s the same process.
 
Upvote 0
I must admit I don't even fully understand the post...

Though, what I understand is that there is a lack of understanding of container concepts.

A container is not a vm. A container aims for application level virtualization achieved by encapsulating its runtime environment in a container image: the main application, its dependencies, its configuration files and hopefully a more or less clever entry point script to execute when a container is created based on the image. An entrypoint script usually prepares the container (like rendering env variables into config files) and then starts the main process. A container does not boot and does not start systemd services, as it is nothing else than an isolated process on the host kernel.

It is a bad practice to use docker commit. If done right, it should be never (as in never ever!) necessary to use it. The proper and repeatable way to create a container image, is by writing a Dockerfile and building the image based on the Dockerfile. It allows declaring which command should be used as entrypoint and/or command for the container, which is not possible with docker commit

I am not sure why you don't just use the official images, or at least images of a trusted source (like bitnami or linuxserver images).

Anyway, could you rephrase your post and this time embed everything into context: where does what happen or is supposed to happen?, and how exactly did you do what you do?
 
Upvote 0
This sounds like an Ubuntu question to set a service to auto start, to which using this web search (of your choice) seems to get quite a few results: ubuntu auto start service

An alternative question: why not just run the official MySQL image in its own container and link to it from your container? I do this with Postgres and assume it’s the same process.
sadly because this is Docker we are talking about, normal ubuntu features like systemctl do not exist. As for using the official image. i may fall back to that if all else fails, but this is kind of a learning project for me and i want to learn how to properly start a service like this one and keep it running in a container.
 
Upvote 0
I must admit I don't even fully understand the post...

Though, what I understand is that there is a lack of understanding of container concepts.

A container is not a vm. A container aims for application level virtualization achieved by encapsulating its runtime environment in a container image: the main application, its dependencies, its configuration files and hopefully a more or less clever entry point script to execute when a container is created based on the image. An entrypoint script usually prepares the container (like rendering env variables into config files) and then starts the main process. A container does not boot and does not start systemd services, as it is nothing else than an isolated process on the host kernel.

It is a bad practice to use docker commit. If done right, it should be never (as in never ever!) necessary to use it. The proper and repeatable way to create a container image, is by writing a Dockerfile and building the image based on the Dockerfile. It allows declaring which command should be used as entrypoint and/or command for the container, which is not possible with docker commit

I am not sure why you don't just use the official images, or at least images of a trusted source (like bitnami or linuxserver images).

Anyway, could you rephrase your post and this time embed everything into context: where does what happen or is supposed to happen?, and how exactly did you do what you do?
Your definitely correct about the lack of understanding of container concepts. This is my first big docker project and I am learning the basics.

I was thinking of the container as a "stripped down" VM, thank you for explaining how they differ.

So this reply took me a while to make, because i have been doing a lot of extra research and trying different approaches to make this work. And after spending the entire day on this, i think i will give up my approach, and just use the supported mysql image, or maybe use a VM on the synology through the VMM package.

Thank you for the information. You likely saved me many more days of frustration, and an unreliable final product, if any at all.
 
Upvote 0
If you are still interested in learning it: If you know how to write bash scripts, it should be possible to write a Dockerfile. After all the RUN instructions are just shell commands. The tricky part is usually the entrypoint script, depending on how much "magic" you want to apply before you start the main process.

It is always helpful to take a look at how others solved specific challenges. You can find the Dockerfile and all files it copies into the image during build of most images on Github, Gitlab or other public git hosting platforms. Sometimes you can find the link to the git repo in the Docker Hub description.

The git project to build the mysql image can be found here: GitHub - docker-library/mysql: Docker Official Image packaging for MySQL Community Server. I found the link in the Docker Hub description. Often you can just use {container image repo name} docker git to find the git project.
 
Upvote 0
Solution

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.

Old thread notice: There have been no replies in this thread for quite some time. The last reply was on .
The content in this thread may no longer be relevant. It might be better to open a new thread instead.

Similar threads

That's a brilliant question: you should raise a feature request to Synology. Since they already use a...
Replies
14
Views
5,122
  • Question
Open an issue on that GitHub page. The developers will be glad to assist. OP has posted two threads on...
Replies
5
Views
750
I'm happy with email notifications but in v0.3.3 of dockcheck the author added apprise notifications...
Replies
4
Views
757
Hi, I'll start by saying, my understanding of networking is very limited so I apologize if I'm asking an...
Replies
0
Views
573
You can run cmd.exe to get a command window from which you can execute SSH commands. However, my personal...
Replies
36
Views
2,405
I can confirm it's not in the list. All I've got are the following: Worth noting that I'm already...
Replies
4
Views
854
I would like to thank you all for your efforts, but unfortunately still not working . But I found a...
Replies
23
Views
1,959

Welcome to SynoForum.com!

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

Registration is free, easy and fast!

Back
Top