Connection refused when running flyway in docker - mysql

I'm trying to run flyway from docker following the official repository. When running the folowing cmd:
docker run flyway/flyway -url=jdbc:mysql://localhost:3306/flyway_demo_db -user=* -password=* info
I installed flyway cmd-tool on my machine and ran a similar cmd:
flyway -url=jdbc:mysql://localhost:3306/flyway_demo_db -user=* -password=* info
This works fine. I'm unsure what's causing this since -password is a valid argument. My machine is running on Ubuntu 20.04

I was missing an cmd argument for the docker run command --net="host"
Example that works:
docker run --net="host" flyway/flyway -url=jdbc:mysql://localhost:3306/flyway_demo_db -user=* -password=* info
Source: How to access host port from docker container

Related

Docker failed to start service utility VM (createreadwrite): mysql

I have a a clean Windows Server 2019 VM. I installed docker on it. Then I'm trying to install mysql. I run docker pull mysql it is successfully pulled. When I try to run docker run --name=MySqlServer -d mysql
I receive the following error:
docker : docker: Error response from daemon: failed to start service utility VM (createreadwrite): kernel 'C:\Program Files\Linux Containers\kernel' not found.
I am new to containers and I don't know how to troubleshoot this issue. I have already set experimental:true to daemon.json

MySQL docker image takes too long to start up the dbms server and socket. ERROR 2002 (HY000): Can’t connect to local MySQL server through socket

Issue type:
initialization bug with mysql:8 docker official image.
Versions:
Docker version 20.10.14, build a224086;
Linux Ubuntu 21.10 host machine OS;
Docker mysql:8 and mysql:oracle official image tags, both with same bug.
Steps to reproduce:
run mysql:8 docker official image from docker hub passing the needed args at the CLI env variables. Such as:
sudo docker run --name app-mysql-container -v [some-absolute-path-in-your-host-machine]:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=[some-root-password] -e MYSQL_DATABASE=[some-database-name] -e MYSQL_USER=[some-user-name] -e MYSQL_PASSWORD=[some-user-password] -d mysql:8
use another instance of the terminal to follow the logs live of the container just created:
sudo docker --follow logs app-mysql-container
then use at the other instance of the terminal:
sudo docker exec -it app-mysql-container bash , in order to get inside the container bash shell, and type:
mysql -u root -p
[type password]
ERROR HAPPENS CONTINUOUSLY until server finishes getting up - about 8 minutes !!
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
after the 8 minutes, when the mysqld server finally gets ready for connection, with a ready socket connection at 3306 port, then everything starts working fine... both for access from inside the container (MySQL CLI) as from outside linked containers with applications connecting to the mysql server.
Eventually the MySQL server starts almost instantly, rather than after 8 minutes... something is wrong with this docker image...
Printscreens below:

docker to connect with mysql database of host system and dump the sql file into host system and then host a web application

I am new to Docker but i have read quite about it. Now my requirement is:
I will give my client a shell script which he would run on a base ubuntu os on a completely new system. The docker image should use the database of host system. The shell script will do all the prerequisites of installing docker, mysql, etc. and will run a docker image. As the image is not available locally, it will pull from docker repository.
Now my problem is that i dont want to give my client the sql dump file just like that. The dump is included in the image and once the images is run i want the image to connect to the host database and dump the data and then host the webapp.
My docker file is :
FROM ubuntu:14.04
MAINTAINER test_manoj
RUN pip install requirements.txt
ADD . /home/myapp/
RUN sudo apt-get install -y supervisor
WORKDIR /home/myapp/
EXPOSE 8000
EXPOSE 80
cmd ["supervisord", "-c", "/home/myapp/supervisord.conf"]
There are some more apt-get install-s but i didnt find it useful to mention here. So basically i am installing nginx, uwsgi, supervisor.
I have exposed port 8000 for socket uwsgi connections and port 80 for nginx.
My docker run command is :
docker run --detach --net=host -v /var/run/mysqld.sock:/var/run/mysqld/mysqld.sock manoj/mydocker
I am using -v to connect the host mysql to container's mysql.
I have already found a work around for my problem that is running
docker run --rm --detach --net=host -v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock manoj/mydocker mysq -uroot -proot db_name < dump.sql
before the main run command. I know this works but is there any other way to do this? And is there any other way i can use host's mysql without providing -v tag?

mysql with Exited(1) from docker

Start learning docker and try to setup a mysql container. But it dies immediately with Exited(1).
Following is the command used
docker run mysql -e MYSQL_ROOT_PASSWORD=password1
Looking at docker ps, it does not show any running docker container
with docker ps -a returns the following :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e681f56c52e2 mysql "/entrypoint.sh -e MY" 3 seconds ago Exited(1) 3 seconds ago lonely_rosalind
Nothing shows up for docker logs lonley_rosalind either
Any idea how to determine why if failed ?
I am running
ubuntu 15.04
docker version 1.9.1 build a34a1d5
Try this
docker run -e MYSQL_ROOT_PASSWORD=password1 mysql
When you are writing something after docker image name docker accepts it as a command for execution in your created container. Pattern for docker run:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

unable to connect to dockerized mysql container locally

I am still a beginner with docker, trying to use docker to help in my development prototyping. My environment is Mac using boot2docker, version as below
Client version: 1.3.1
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 4e9bbfa
OS/Arch (client): darwin/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa
I ran the command as below:
docker run --name mymysql -e MYSQL_ROOT_PASSWORD=mypw -e MYSQL_DATABASE=bullshit -d mysql -p 3306:3306
docker start mymysql
I can see the process running as below:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
22d3f780c270 mysql:5 "/entrypoint.sh -p 3 2 minutes ago Up 2 seconds 3306/tcp mymysql
However I still could not connect to the mysql instance running in the docker. I tried connect to the ip retrieved by :
$ boot2docker ip
The VM's Host only interface IP address is: 192.168.59.103
Please give me a pointer on how to solve this issue, I went through the tutorial but I am not sure what went wrong.
The command you used should give an error. The syntax for docker run is as follow:
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
You have to submit the options to docker run before specifying the image used (mysql in your case), and if it's the case, the command and possible argument(s) to that command.
Not specifying a command will run the default command in the image.
Before running again the container you should stop and remove the old one:
docker kill mymysql
docker rm mymysql
And, following your example you should run:
docker run --name mymysql -e MYSQL_ROOT_PASSWORD=mypw -e MYSQL_DATABASE=bullshit -p 3306:3306 -d mysql
As you set manually a port mapping from container's port 3306 to the same port of your Boot2docker VM, you should can access to MySQL using the IP of the Boot2docker instance, typically 192.168.59.103, and connecting to port 3306.