can't control terminal after using the "-t" option in Docker - docker

I am working through the Docker tutorial from here: https://docs.docker.com/language/python/develop/
I have done the first few steps from the tutorial to create a MYSQL container:
$ docker volume create mysql
$ docker volume create mysql_config
$ docker network create mysqlnet
$ docker run --rm -d -v mysql:/var/lib/mysql \
-v mysql_config:/etc/mysql -p 3307:3306 \
### (note: I used 3307:3306 here instead of the specified 3306:3306 because port 3306 was already being used on my machine) ###
--network mysqlnet \
--name mysqldb \
-e MYSQL_ROOT_PASSWORD=p#ssw0rd1 \
mysql
I then followed the next step to check if the mysql container was running:
$ docker exec -ti mysqldb mysql -u root -p
the terminal then prompts:
Enter password:
and I am unable to enter anything. no commands seem to work. ctrl+C didn't even register. the only thing I could do was kill the terminal itself. I am very confused since I have been following the documentation very closely though I am sure it's something very dumb.
Thanks in advance!

Try:
$ docker exec -ti mysqldb bash
then:
mysql -u root -p
I think you can connect with shell first

Related

Unoconv call (openoffice) from other container

I am new in linux and docker. I need to convert odt files to pdf from php container. I use php-5.6-apache and https://github.com/xiaojun207/openoffice4-daemon:
sudo docker build --pull
-t xiaojun207/openoffice4-daemon
–build-arg OO_VERSION=4.1.7 .
sudo docker run -d --restart unless-stopped
-u 123456
–name soffice
–net my-network
-p 8100:8100
-v /data/output-odt:/pdfs/:rw
xiaojun207/openoffice4-daemon:latest
sample of openoffice4-daemon works well from host:
sudo docker run
-v /var/output-odt:/pdfs:rw
xiaojun207/openoffice4-daemon
–net my-network
unoconv --connection ‘socket,host=127.0.0.1,port=8100,tcpNoDelay=1;urp;StarOffice.ComponentContext’
-f pdf /pdfs/test.odt
But I need to execute it from my php container. docker run is not possible from other container. How can I do it? Thanks

nextcloudpi in docker: Cannot use mounted external storage

Recently I installed nextcloudpi in docker with
sudo docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /home/user/storage/nextcloud:/data --name nextcloudpi ownyourbits/nextcloudpi-armhf <ip-adress-of-pi>
the folder /home/user/storage is a mounted external storage (following this tutorial https://www.techjunkie.com/build-nas-raspberry-pi-linux/)
It get me the error:
Running nc-init
Setting up a clean Nextcloud instance... wait until message 'NC init done'
Setting up database...
Setting up Nextcloud...
Console has to be executed with the user that owns the file config/config.php
Current user: www-data
Owner of config.php: root
Try adding 'sudo -u root ' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u root' to the docker command (without the single quotes)
I tried
sudo docker run -d -p 4443:4443 -p 443:443 -p 80:80 -v /home/user:/data --name nextcloudpi ownyourbits/nextcloudpi-armhf <ip-adress-of-pi>
and everythink workes well as far as I can tell. I can load the nextcloudpi config UI as well as the nextcloud GUI.
I have tried some chown and chmod for the /home/user/storage folder, without any succes.
How can i use the external storage as directory of the nextcloud?

I try to mount a created database from host, name mydb, onto mysql container here is what I’ve tried:

I try to mount a created database from host, name mydb, onto mysql container here is what I’ve tried:
sudo docker run -v mysql-data:/var/lib/mysql/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
root#ip-172-31-16-134:/var/lib/mysql# sudo docker run -v mysql-data:/var/lib/mysql/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
3c0a8eb588c0dd0d0b7b72a727912744f44e744e700de7efc64a0c4c1f651685
root#ip-172-31-16-134:/var/lib/mysql# docker exec -it mysql_web bash
Error response from daemon: Container 3c0a8eb588c0dd0d0b7b72a727912744f44e744e700de7efc64a0c4c1f651685 is not running
but it works when I change where to mount…
sudo docker run -v mysql-data:/var/lib/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
root#ip-172-31-16-134:/var/lib/mysql# sudo docker run -v mysql-data:/var/lib/mydb/ --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7
06233eeb864c32ff16d6542e632a4da3ff6dfbd4a30fcc9aac8086dfc1245948
root#ip-172-31-16-134:/var/lib/mysql# docker exec -it mysql_web bash
root#06233eeb864c:/# cd /var/lib/mydb
root#06233eeb864c:/var/lib/mydb# exit
exit
seems It can’t mount onto specific folder and I don’t know why, I just want both databases, one from host, and the other from container, synced itself instead of loading dump.sql everytime when I start a new container.
any suggestion would help , thanks
This is known issue for the error you got [ERROR] --initialize specified but the data directory has files in it. Aborting.
What this error means is explained here.
Try few things like
Adding --ignore-db-dir=lost+found as mentioned here.
Providing exact path of data directory on host and mount on to container path at /var/lib/mysql like this docker run -v /path/to/mysql-data:/var/lib/mysql --name mysql_web -e MYSQL_ROOT_PASSWORD=12345 -p 3306:3306 -d mysql:5.7 as mentioned here.
Hope this helps.

docker mysql, send sql commands during exec

i am creating a mysql 5.6 docker using bash script and i would like to change the password.
how can i send sql commands from bash to docker?
build:
sudo docker build -t mysql-5.6 -f ./.Dockerfile .
run.sh:
#!/bin/bash
sudo docker run --name=mysql1 -d mysql-5.6
sudo docker exec -it mysql1 mysql -uroot -p$base_password \
<<< SET PASSWORD FOR 'root'#'localhost' = PASSWORD('new_pass');
You need to bind MySQL-port like descriped here. To keep the port 3306 you can just expose it on your host the following way:
sudo docker run --name=mysql1 -p 3306:3306 -d mysql-5.6
After that you should be able to use mysql -u USER -p PASSWORD on your local host. This will then allow you to send commands to your docker-container.

cannot run container after commit changes

Just basic and simple steps illustrating what I have tried:
docker pull mysql/mysql-server
sudo docker run -i -t mysql/mysql-server:latest /bin/bash
yum install vi
vi /etc/my.cnf -> bind-address=0.0.0.0
exit
docker ps
docker commit new_image_name
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -d new_image_name
docker ps -a STATUS - Exited (1)
Please let me know what I did wrong.
Instead of trying to modify an existing image, try and use (for testing) MYSQL_ROOT_HOST=%.
That would allow root login from any IP. (As seen in docker-library/mysql issue 241)
sudo docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_ROOT_HOST=% -d mysql/mysql-server:latest
The README mentions:
By default, MySQL creates the 'root'#'localhost' account.
This account can only be connected to from inside the container, requiring the use of the docker exec command as noted under Connect to MySQL from the MySQL Command Line Client.
To allow connections from other hosts, set this environment variable.
As an example, the value "172.17.0.1", which is the default Docker gateway IP, will allow connections from the Docker host machine.

Resources