Exposing Docker-MySQL container on Azure to be used as DBaaS - mysql

I want to make specifically a docker container that holds standard Docker Hub MySQL image.
Once this container is deployed using Azure Container services, how do I use it remotely?
I want to connect to this (container-hosted) mysql server remotely, so that my APIs can upload data to this database over internet.
Where do I find host,username, password for this hosted MySQL db?

Once this container is deployed using Azure Container services, how do
I use it remotely?
If you deploy the container to Azure Container Service, you can use a service with the LoadBalancer type to expose the port of the container to access outside.
Where do I find host,username, password for this hosted MySQL db?
You can use the environment variables to set the user and password. Except this, you can connect into the container, then go inside the MySQL and create the users manually.

Related

Connect localhost Mysql from Docker .net core

I have working WebAPI in .net core in Docker. I want to deploy this API on AWS EC2 instance with local mysql database working with other web app.
How can I reach this Mysql from inside docker?
Locally I can do it by using my private ip addres in
=> optionsBuilder.UseMySql(#"Server=$my_local_ip;database=db_name;uid=user;pwd=pass;");
Ho to determine which $my_local_ip should I use in order to connect to DB?
But while using the private ip on EC2 I got error while sending request that it can't connect to any MYSQL host.
For MySQL server you generally have to specify the port to connect to, as each instance on the same server uses a different port.
Use --network=host flag while starting the Web API container and use the localhost in you connection string as the host name. This will enable the Docker container to access the host network. Hence you can access MySQL Database from the container.
Note: This is an insecure for running containerized workloads. Click Here to learn more

Mysql in container or different VM

I am running MySQL database on different VM (separate from web server).
Because of separate VM I can protect database by giving access permission to only server and closing all other ports other than 3306.
Now, with docker I can set up LAMP server in one container and MySQL in other. How secure and scalable is this solution?
I am not sure how this type of things work with container services!
protect database by giving access permission to only server and closing all other ports other than 3306.
You can do that with Docker containers. Take a look at Docker Expose.
Not sure what you mean by "scalable" here. See the documentation for scaling containers in general. Usually it's not very difficult.

mysql docker container start with a fixed ip

hi I have a mysql container running as a service, and for other services connect it with a jdbc url, with a ip:port.
and for sometimes the server needs to reboot. and the ip addr of mysql container will change, for every service needs to connect to mysql, the jdbc url needs to be modified.
is there a way to 'docker start' a container with a fixed ip address?
I've tried --ip but it's not working
docker version 1.11.2
You can preset an IP to a container, but this must be done when you create the container (in the docker run).
https://docs.docker.com/engine/reference/run/
To preset an IP to a container you ahve to add the switch --ip="desired_ip_here" in the docker run
Also you can use tools like supervisord to manage you processes and restart services without stopping the container.

run multiple mysql pods in kubernetes

I would like to create a kubernetes cluster to deploy mysql databases, like a mysql farm. These databases should be accessible from internet.
All databases on the same node will have the port 3306 listening, the kube-proxy or the DNS addon could redirect each request to an specific container?
I would like to create url's like myDB1.example.com:3306, myDB2.example.com:3306 that goes to an specific container.
I'm deploying this environment in AWS.
It's possible to create this cluster?
Yes. Starting point would be a (customized) MySQL Docker image with EBS backed volumes and you'd be using it in an Replication Controller to handle failover. On top of that you would have a Service that provides a stable and routable interface to the outside world. Optionally, put an AWS Elastic Load Balancer in front of it.

Connect to mysql docker on tutum endpoint

I'm using Tutum to host my application via docker. The first container needed is offical mysql container. I already got it up & running. After that, Tutum provide a service endpointfor me to connect to it:
However, I don't know how to connect to it via the provided endpoint (especially using Sequel Pro). Could anyone help me to figure this out?
As mentioned in "tutum support: Your first service", then endpoint is the url with port exposed by the image.
You would use it as an external client accessing to that url.
Note that you can set a port to be publish statically instead of dynamically (-p x:y instead of -P, in docker run lingo)
But in case of your containerized application, you don't need that endpoint.
Your container, if linked to the mysql container, you will be able to use mysql services from your app container directly.
See "Service discovery and links"
You don't have to use the full endpoint url from your app container.
Note that tutum:
provide a simple way to connect any container on any stack to any other container on your account without having to create service links.
A container can always discover other containers on the same stack using the container name as hostname.