【已解决】 docker-compose创建MySQL容器失败
version: '3.1'
services:
mysql:
container_name: "sob-blog-system-mysql"
network_mode: "host"
environment:
MYSQL_ROOT_PASSWORD: "123456"
MYSQL_USER: 'root'
MYSQL_PASS: '123456'
image: "mysql:5.7.31"
restart: always
ports:
- 3306:3306
volumes:
- "/mnt/c/Users/ChengWei/docker/mysql/db:/var/lib/mysql"
- "/mnt/c/Users/ChengWei/docker/mysql/conf:/etc/mysql"
- "/mnt/c/Users/ChengWei/docker/mysql/log:/var/log/mysql"
用的是上面的docker-compose.yml,但是创建后mysql容器总是不断aborting而后重启,容器的log如下:
2020-09-17 13:22:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
2020-09-17 13:22:14+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-09-17 13:22:14+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
2020-09-17 13:22:15+00:00 [Note] [Entrypoint]: Initializing database files
2020-09-17T13:22:15.295747Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-09-17T13:22:15.346841Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2020-09-17T13:22:17.484906Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-09-17T13:22:17.964250Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-09-17T13:22:18.027924Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cf2edc2f-f8e8-11ea-a3f4-025000000001.
2020-09-17T13:22:18.046982Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
mysqld: Can't change permissions of the file 'ca-key.pem' (Errcode: 1 - Operation not permitted)
2020-09-17T13:22:18.251062Z 0 [ERROR] Could not set file permission for ca-key.pem
2020-09-17T13:22:18.251095Z 0 [ERROR] Aborting
请大家帮忙看看怎么解决这个log?
1、我感觉你的配置文件不对,每个冒号后都有空格,其次是volumes不对
2、实在是运行不了的话,也可以考虑在本地装个mysql,也能实现功能
1、你说的用另一种方法实现,我感觉也有点问题
2、其次是
可以更改为这个吗
3、你可以尝试打开浏览器看是否能联网。你说的连接不上,我当初在虚拟机里整的,也连接不上过,是因为虚拟机没有连上网,后来网络通了所有都正确了。
4、我找了个链接可能对你的问题有帮助
为啥康师傅idea可以点进去看
就是说 如果我用docker-compose这种方式的话,那么生成的容器是在/mnt/c/Users/ChengWei文件夹下面,如图所示
然后我用ifconfig得到的ip是172.18.87.1,问题是始终连不上navicat
如果我不用这种docker-compose,而用这个
这个时候生成的容器就是独立的,不在chengwei文件夹下,用ifconfig里面的这个ip就可以连接了,如图
想问怎么解决docker-compose在文件夹里面这种情况,怎么看这个情况下的ip?
permission 留意这个。
你可以运行compose前面,增加
sudo