I'm following this guide to use MySQL 8.0 in Docker (on macOS host), but I'm having some issues. I have no Docker experience other than this, so please be easy on me. I tried to debug as best I could. It seems the author of the guide has some outdated commands/syntax errors (not sure which), which I think I've fixed. However, when I try to run the following command, I keep getting the error below:
Command:
docker run --restart always --name mysql8.0 --network dev-network -v /Users/[my-name]/mysql/data/8.0:/var/lib/mysql -p 3306:3308 -d -e MYSQL_ROOT_PASSWORD=[my-password] mysql:8.0
( [my-name] and [my-password] are subbed out).
Error:
"docker run" requires at least 1 argument.
I've checked docker run --help but can't get any further.
I've also found this question and this question, but those cases seem highly specific to the OPs' situation, so the answers didn't yield any successful results for me.
Any help or suggestions are appreciated.
The command you've pasted works fine. There is a possibility that the password you're entering has some special characters making the shell think of it as something else. (Or your volume next to -v flag has some special characters).
Just to test, try with a simple password like this:
docker run --restart always --name mysql8.0 --network dev-network -v /Users/[yourusername]/mysql/data/8.0:/var/lib/mysql -p 3306:3308 -d -e MYSQL_ROOT_PASSWORD=testpass
mysql:8.0
Related
Hello currently I get in touch with Docker. I am doing their getting started and I ran into a problem which I cant solve and I dont understand why it dont work. First of all I create a network using.
$ docker network create todo-app
After that, I set up a Container mysql database and connect it with the network with following code.
$ docker run -d \
--network todo-app --network-alias mysql \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
I check for the Container id with
$ docker ps
After that I use the command to get into the mysql CLI ? (not sure on that yet)
$ docker exec -it mysql -u root -p
After getting there I use
mysql> SHOW DATABASES;
to show all DB on my PC? But there is non listed named todos and i dont know why it dont appear.
I would like to hear what you are thinking im struggeling a little there. Thanks for the replies. Sorry for my english skills.
Run container in the foreground and check the logs.
Following Part 7: Multi-container apps, I ran into this exact issue just now.
Chances are, you have run that same command at least once.
# command to run as per the docs
docker run -d \
--network todo-app --network-alias mysql \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
And the first time you ran the command you unknowingly made a mistake. For me, I mistyped MYSQL_DATABASE FOR MYSQL_ROOT_PASSWORD. Yours might be different. In any case, it seems making small mistakes like this might have caused the mysql:5.7 image to not be set up correctly with the todos database. (Not entirely sure.)
Adding to that, the first time you run that command, Docker creates a todo-mysql-data volume, which does not get overwritten when you run that same command again.
So as a "fix", you might have to delete the todo-mysql-data volume first.
docker volume rm todo-mysql-data
And then re-create the todo-mysql-data volume implicitly by re-running the image with the above command; this time without mistakes.
Sorry for the trouble it was my fault I guess cause I used the Command I pointed out above but I definetly had to use this command :
docker run -d \
--network todo-app --network-alias mysql \
--platform "linux/amd64" \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
Because im using Linux... Such a dumb mistake but i swear this wasnt there two months ago when I asked this Qeustion.
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
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
I am trying to serving my model using TensorFlow with docker. I downloaded Docker for windows and tried the code as per the documentation.
!docker pull tensorflow/serving
!git clone https://github.com/tensorflow/serving
TESTDATA="/serving/tensorflow_serving/servables/tensorflow/testdata"
Above code worked fine .But when i tried below code
!docker run -t --rm -p 8501:8501,-v "TESTDATA/saved_model_half_plus_two_cpu:/models/half_plus_two",-e MODEL_NAME=half_plus_two,tensorflow/serving
It is giving below error.
docker: invalid reference format.See 'docker run --help'..
Any idea guys please help.
#BSP This worked for me:
docker run -t --rm -p 8501:8501 -v "$testdata/saved_model_half_plus_two_cpu:/models/half_plus_two" -e "MODEL_NAME=half_plus_two" tensorflow/serving
I am trying to use a MySQL image on docker, attaching a volume, furthermore I would like to add a sql script in order to create a table if not present yet.
So if the container is used in another machine the table will be Always present.
My command :
docker run -d -p 3306:3306 --name my-mysql --network sma -v /scripts:/docker-entrypoint-initdb.d/ -v /myvolume/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=myDB mysql
My situation:
I am able to attach the volume with -v option (/myvolume/:/var/lib/mysql) during the run, and actually I am also able to insert the script in the init directory ( /docker-entrypoint-initdb.d/ ) but if I do these two things, only the volume attaching will work.
I guess it is something like the script is executed (because it is placed in the directory) but then the MySQL is overwritten by the volume attaching, so the only thing I am seeing is what is present in myvolume.
There is some way that makes that work?
I resolved using it in a swarm from a docker-compose with docker stack deploy -c docker-compose.yml swarm_name.
In the service definition of the docker-compose I added the command line in order to force it to execute the init script.
command: --init-file /docker-entrypoint-initdb.d/initDb.sql