docker 1.7 multiple port mapping at run failure - mysql

Background:
Ubuntu 14.04 LTS - Docker 1.7 - Virtual Interface with its own IP specfically for use with Docker.
Running Wordpress Latest with linked MySQL 5.7 each with their own data containers.
I need to map ports 80 & 443 to the Wordpress container to enforce SSL site wide.
This run string works perfectly:
docker run --name Web --link db-server:mysql -d -e WORDPRESS_DB_NAME=WP -e WORDPRESS_DB_USER=admin -e WORDPRESS_DB_PASSWORD=somepassword -p 172.31.25.94:80:80 --volumes-from wp-data wordpress
When I run this string I get an error:
docker run --name Web --link db-server:mysql -d -e WORDPRESS_DB_NAME=WP -e WORDPRESS_DB_USER=admin -e WORDPRESS_DB_PASSWORD=somepassword -p 172.31.25.94:80:80 —p 172.31.25.94:443:443 volumes-from wp-data wordpress:latest
Error message:
Unable to find image '—p:latest' locally
Invalid repository name (—p), only [a-z0-9-_.] are allowed
I have read the Docker documentation and Googled for this issue and from everything I have found this should work. Is there something I am missing or is this not possible in 1.7?

Related

mysql docker container - cannot connect with windows

I am very sorry guys, I found several topics on stackoverflow but none of them solved my issue. I am a docker noob, but all I want to do is connect to my docker mysql database in a docker container created via docker-desktop on windows.
docker run -p 3306:3306 --name blaaa -e MYSQL_ROOT_PASSWORD=password -d mysql
I set up everything with the suggested port mapping, but I cannot connect to the docker container from the host (windows 10) via mysql-workbench or other programs. I read that there are issues and you often cannot connect to the docker host via localhost, but I cannot even figure out what the freakin ip of docker0 or other adapters is (ipconfig does not show anything). docker inspect <id> shows a lot of information, but besides mapping to 0.0.0.0:3306 and other ips that don't work, I cannot really figure out what to do here. the container itself is running fine and I can access the database from inside the container without any issues.
thanks for your help!
/SOLVED
I am sorry for the confusion; I think it was due to the Windows clients (I tried several) that things didn't work out. I finally got it working with HeidiSQL. Don't ask me how or why HeidiSQL finally works; but mysql-workbench generally showed strange behavior on my system, it crashed several times out of the blue. Thanks for your help.
Hey when you don't specify the database name, the container will stop as soon as it created, so specify the database name as environment variable
this is the docker command :
docker run -p <host_machine_port>:3306 --name <container_name> -e MYSQL_ROOT_PASSWORD=<root_password> -e MYSQL_DATABASE=<db_name> -d mysql
in your case :docker run -p 3306:3306 --name blaaa -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE= testDB -d MySQL
And next verify if the container running or not: docker ps
if it shows the container name you specified when you created it, it's running.
next connect to your container : mysql --host=127.0.0.1 --port=3306 -u root -p password
this works
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d -p 3307:3306 mysql
reason explained here -p is an argument
https://github.com/docker-library/mysql/issues/504

using docker images for mySQL and redmine, how do I resolve "Unknown MySQL server host"?

I am using the docker images supplied at https://hub.docker.com/_/redmine
I have chosen to use MySQL as my database backend. So I have 2 docker containers: MySQL and Redmine, as downloaded from dockerhub.
Following the instructions on the docker/redmine link above, I ran through the commands and found that the redmine docker would not start. Inspecting the docker logs, I see:
rake aborted!
Mysql2::Error::ConnectionError: Unknown MySQL server host redmine (-5)
I thought the 2 dockers were having difficulty talking to each other, so I setup a new docker network for both containers to use:
docker network create --driver bridge redmine-net
Adapting the instructions, on the docker/redmine link above, I run
docker run -d name our-mysql --network redmine-net -e MYSQL_USER=redmine -e MYSQL_PASSWORD=todays-password -e MYSQL_DATABASE=redmine -e MYSQL_RANDOM_ROOT_PASSWORD=1 -p 3306:3306 mysql:5.7
docker run -d name our-redmine --network redmine-net -e REDMINE_DB_MYSQL=redmine -e REDMINE_DB_USERNAME=redmine -e REDMINE_DB_PASSWORD=todays-password redmine:latest
However, the redmine contain still falls over instantly, with the same error.
EDIT Using the *.yml file as provided in the dockerhub redmine instructions works pretty faultlessly.
So the question is: what is the docker-compose method doing that docker run isn't handling?
Thank you.
The REDMINE_DB_MYSQL arg of the redmine container do reference to the mysql container, so, if you define the database service like our-mysql, then set REDMINE_DB_MYSQL=our-mysql

Docker, unable to connect WordPress to MySQL

I'm trying to link two containers together, I was able to connect a PhpMyAdmin container with a MySQL container, but nothing seem to work when I'm using a WordPress container.
I tried different things, actually I'm using this command to run a MySQL container:
sudo docker run --name sql -e MYSQL_ROOT_PASSWORD=pass mysql
and this one to set up the WordPress container:
sudo docker run --name wpress -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=pass -e WORDPRESS_DB_HOST=172.17.0.2 -p 8085:80 --link sql:mysql wordpress
MySQL container work fine, but I have this output from wpress:
MySQL Connection Error: (2054) The server requested authentication method unknown to the client
Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Standard input code on line 22
What I am doing wrong?
Edit:
I was able to connect the wpress container to sql container a couple of time during some test by adding a port to WORDPRESS_DB_HOST, which will give:
sudo docker run --name wpress -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=pass -e WORDPRESS_DB_HOST=172.17.0.2:3306 -p 8085:80 wordpress
(I also remove the --link option, it worked without it).
So it work 2-3 times, but it doesn't work anymore.
It seem to be a version error. Use an image with a different version of mysql, mysql:5.7 for example, and it should work.
I had same problem/error.
This is what I had to do for mysql and wordpress:
docker run --name wordpressdb -e MYSQL_ROOT_PASSWORD=password -d mysql
docker exec -it wordpressdb bash
#inside run:
mysql -uroot -ppassword
#paste
ALTER USER 'root'#'%' IDENTIFIED WITH mysql_native_password BY 'password';
exit
exit
docker run --name wordpress -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=password -p 8080:80 --link wordpressdb:mysql -d wordpress

I can't seem to get my local shared MySQL data volume to persist on Docker for Windows

I'm using the latest Docker for Windows on Win 10 with following run command:
docker run -d -e APP=db -e MYSQL_ROOT_PASSWORD=password -v /C/Users/myuser/Documents/mysql_data:/var/lib/mysql --name=db -p 3306:3306 mysql:latest
When I start the container and check the ~/Documents/mysql_data directory, there's nothing there.
The data persists reboot, but when I stop, remove and re-run the container, the data is gone.
I am on a security-restricted Windows 10 laptop with 16GB of RAM, where sharing files works fine for my PHP container with a similar run command.
I expected to have MySQL's ibData files in my local mysql_data directory and the ability to persist container re-run. Is this a bug, or am I getting the expected behavior or doing something wrong?
Edit: When I docker exec -it bash db into the database container, there's this output when I df -h
//10.0.75.1/C 236G 109G 127G 47% /var/lib/mysql
you can show docker logs:docker logs db
try follow:
docker run -d -e APP=db -e MYSQL_ROOT_PASSWORD=password -v /C/Users/myuser/Documents/mysql_data:/var/lib/mysql:rw --name=db -p 3306:3306 mysql:latest

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.