Install the app
How to install the app on iOS

Follow along with the video below to see how to install our site as a web app on your home screen.

Note: This feature may not be available in some browsers.

Starting mysql on container start

As an Amazon Associate, we may earn commissions from qualifying purchases. Learn more...

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.

Popular tags from this forum

Similar threads

  • Question Question
Can you share how you deployed the containers? If it was not based on a compose file, your containers are...
Replies
6
Views
326
A simple update will do just fine. The fact that the container will be destroyed and rebuild, it also...
Replies
5
Views
124
To move, backup and restore Container Manager or Docker use...
Replies
8
Views
349
I finally got it to update. For some reason when I'd try to either duplicate the original container or...
Replies
5
Views
515
Thank you so much for the help! My gateway is 192.168.1.1 DHCP network is 192.168.1.0/24 on DSM I want...
Replies
3
Views
1,197
Another aspect that might indicate it is that the swarm mode finally works! It is the first Synology...
Replies
4
Views
1,729
Replies
3
Views
1,600

Thread Tags

Tags Tags
mysql

Welcome to SynoForum.com!

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

Registration is free, easy and fast!

Trending content in this forum

Back
Top