How to link a running docker container with mysql? - mysql

I want to connect my already running jenkins container with mysql database which is another container. Have created a database named jenkins and user named jenkins in mysql.
Can it be done without using the run command coz run installs a fresh image and i want to use the existing one.

You can use docker network connect to connect both containers to the same network, so they can communicate. See docker network connect

Related

How to install only specific mysql client functions

I have a docker container and need the abillity of mysqldump and importing sql files to a external mysql server. So i dont need the Server engine in my docker container. I just need the abillity of running mysqlcommands.
So how can i just install this abiolity with minimal space requirement in my docker container?

How to Connect to Dockerized MySQL Database running on EC2 from Flask Web App

I am attempting to connect to a MySQL Database that is dockerized and stored in EC2 from a Flask Application. In order to get to the database manually, you have to ssh in with a pem file and then exec into the docker image to get to the database. How would I go about connecting to this from the application itself. I have tried using both sql alchemy or mysql but if I try and use the ip address to the ec2 instance it just times out. My guess is I need to do something with a Dockerfile within the Flask app maybe? I am fairly new to Flask and Docker so I am not sure what the best course of action is and could not find a lot of information online.
In short, if you are able to connect to the MySQL server with one of MySQL client tools, then you'll be able to connect to it with Flask.
The process is not that simple, I can't give you commands to execute without any additional info, but overall logic is the following.
MySQL has a server inside the docker container working on 3306 port. First, that port should be exposed to the server and probably bind to the server's 3306 port, this may be done on the docker run command.
You need to run something like docker run -p 3306:3306. See more details here
Second, if you want to connect to the instance from remote, you need to make sure the port is accessible from wherever you want, docker will automatically add an iptable record for you, but make sure if there is not a firewall blocking the port.
Given you are receiving a time-out, most probably the issue is that Flask is not able to connect through that port.

Altering schema in dockerized MySQL database

How is MySQL in Docker used in Production when updates are necessary.
For example, adding a column or table, etc.
Is there a way of using Liquibase?
Technically, you can run MySQL in a Docker container just like you'd run MySQL on a VM. Once deployed in a container, you can run any MySQL SQL via mysql client (or any client including JDBC) as long as you have the container running at a resolvable address and have the right credentials. The client doesn't know (or care) that your MySQL server is running in a container - all client cares about is the host, port, database and user/password values.
That said, you need to make sure you mount a volume for your container so that MySQL data can be "externalized" and you don't lose everything just because you ran a docker rm. With plain Docker, you can use the -v option to mount a voulme from the Docker host VM or an external disk (such as EBS or EFS/NFS). With Kubernetes, you can use a statefulset with a persistentVolumeClaim to make sure you preserve the storage no matter what happens to your container.
Mysql on docker acts mostly as an standalone Mysql installation. Be careful to configure a volume for the data or you will lose upon container restart or termination.
Said that, you can use any mysql consuming app, as you only need is to expose the port, and configure crendentials.

How can I shard MySQL database with Vitess using both Docker images?

I found out about Vitess which let you shard MySQL database.
I want to use the docker image of both MariaDB and Vitess but I'm not quite sure what to do next. I'm using CentOS 7.
I installed the images
docker pull mariadb
docker pull vitess/root
docker pull vitess/orchestrator
Log inside the vitess image
sudo docker run -ti vitess/root bash
As the website said, make build
make build
I set up the variables
export VTROOT=/vt
export VTDATAROOT=/vt/vtdataroot
The manual said it was in the home directory but in the image it's at root.
But after that I'm stuck. I laucnh zookeeper : ./zk-up.sh
Starting zk servers... Waiting for zk servers to be ready... Started zk servers. ERROR: logging before flag.Parse: E0412
00:31:26.378586 132 syslogger.go:122] can't connect to syslog
W0412 00:31:26.382527 132 vtctl.go:80] cannot connect to syslog:
Unix syslog delivery error Configured zk servers.
Oops, okay, let's continue...
./vtctld-up.sh for the web internace
Starting vtctld...
Access vtctld web UI at http://88bdaff4e181:15000
Obviously I cannot access that link since it's in docker on a headless server
./vttablet-up.sh suppose to bring up 3 vttablets, but MariaDB is in another docker, not yet started and if I open the file it is not apparent how to set it up.
Is there any MySQL or PostgreSQL sharding solution more easily installable?
Or how can I set this up?
(Docker noob here sorry)
Thanks!
If you need multiple container orchestrated, best bet is to use docker-compose. You can define all the application dependencies as separate containers and network them to be accessible from each other.

How to use Navicat to connect to the MySQL database in Openshift

I'm using openshift to build my apps.
And I add mysql to my gear.
but, if I want to reach my database. I can't use Navicat which is my usual way to manage my database. I must ssh to my openshift server and then use command line 'mysql' to reach my database which is a bad way compared to Navicat.
So, how can I reach my database in Openshift with Navicat?
I've used env | grep MYSQL to get my mysql configration and use it in Navicat.
However, all is none effect.
If its a scalable application you should be able to connect to it externally via the connection information supplied by the environment variables. If its not a scalable app, then you'll need to use the rhc port-forward command to forward the necessary ports needed to connect.
Take a look at the following article here for more information. https://www.openshift.com/blogs/getting-started-with-port-forwarding-on-openshift