Docker-MySQL修改端口映射
banner 2020-10-12 23:27:47 dockerMySQL
# 一、修改方式一
# 1、停止容器
docker stop mysql
1
# 2、获取容器的完整ID
docker inspect mysql
1
[
{
"Id": "837fb28c0321c3ebb291e8be8b209e7d25eacb436802ca8a4ed046bcfbcaa10a",
"Created": "2020-05-28T08:19:34.034271013Z",
"Path": "docker-entrypoint.sh",
"Args": [
"--character-set-server=utf8mb4",
"--collation-server=utf8mb4_unicode_ci"
],
"State": {
"Status": "running",
......
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# 3、找到配置文件hostconfig.json
打开 /var/lib/docker/containers/[container_Id]/hostconfig.json
文件
找到以下配置
"PortBindings":{
"3306/tcp":[
{
"HostIp":"",
"HostPort":"3306"
}
]
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
修改HostPort即可