[vagrant@docker-node1 ~]$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
makchikin/flask-redis latest 0218f147cf9d 24 hours ago 891MB
redis latest dcf9ec9265e0 4 days ago 98.2MB
python 2.7 e8cff83571c6 4 days ago 886MB
mysql 5.7 1e4405fe1ea9 4 days ago 437MB
nginx latest 231d40e811cd 4 days ago 126MB
busybox latest 020584afccce 3 weeks ago 1.22MB
[vagrant@docker-node1 ~]$ sudo docker run -d -v mysql:/var/lib/mysql --name mysql1 -e MYSQL_ALLOW_EMPIT_PASSWORD=true mysql:5.7
fd0afe7906f4ff5a34be8b78ba4d4e41850ff1da429787afa1587cb23ca43422
[vagrant@docker-node1 ~]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd0afe7906f4 mysql:5.7 "docker-entrypoint.s…" 6 seconds ago Exited (1) 4 seconds ago mysql1
[vagrant@docker-node1 ~]$ docker rm mysqlq
Error: No such container: mysqlq
[vagrant@docker-node1 ~]$ docker rm mysql1
mysql1
[vagrant@docker-node1 ~]$ docker volume rm mysql
mysql
[vagrant@docker-node1 ~]$ sudo docker run -d -it --name mysql1 -v mysql:/var/lib/mysql -e MYSQL_ALLOW_EMPIT_PASSWORD=true mysql:5.7 /bin/bash
25aa375b46d221c407bab67761318248c9c959c21e2ed75660def5991ef8491e
[vagrant@docker-node1 ~]$ docker exec -it mysql1 /bin/bash
root@25aa375b46d2:/# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@25aa375b46d2:/# ps aux |grep mysql
bash: ps: command not found
root@25aa375b46d2:/# musql
bash: musql: command not found
root@25aa375b46d2:/# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@25aa375b46d2:/# sudo service mysql start
bash: sudo: command not found
root@25aa375b46d2:/#
老师您好,我安装您的视频一直操作,如果按照视频里面的命令,
[vagrant@docker-node1 ~]$ sudo docker run -d -v mysql:/var/lib/mysql --name mysql1 -e MYSQL_ALLOW_EMPIT_PASSWORD=true mysql:5.7
54af2087b120bb802dd0ae1e899fa966ac44921fc767f1787addc1031df4a8a8
[vagrant@docker-node1 ~]$ sudo docker exec -it mysql1 /bin/bash
Error response from daemon: Container 54af2087b120bb802dd0ae1e899fa966ac44921fc767f1787addc1031df4a8a8 is not running
容器一运行就关闭了,并且报错,所以我改成了交互式创建和运行容器
sudo docker run -d -it --name mysql1 -v mysql:/var/lib/mysql -e MYSQL_ALLOW_EMPIT_PASSWORD=true mysql:5.7 /bin/bash
[vagrant@docker-node1 ~]$ docker exec -it mysql1 /bin/bash
root@25aa375b46d2:/# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
root@25aa375b46d2:/# ps aux |grep mysql
bash: ps: command not found
但是我一直进不去容器里面的mysql,进入容器里面也没有找到 mysql 有进程在运行,请问这是什么原因导致的呢?谢谢!