目前mac下的docker可以通過(guò)指定特殊的域名來(lái)訪問(wèn)部署在mac主機(jī)上的服務(wù)。
比如訪問(wèn)mac主機(jī)上的mysql服務(wù), 17.12版本之后只需要將host設(shè)置為docker.for.mac.host.internal即可。
mysql_uri = 'mysql://{user}:{password}@{host}:3306/{db}'.format(user="root",
password="",
host="docker.for.mac.host.internal",
db="demo")
參考: