我在Windows环境中工作,我将MySQL数据库放入Docker容器,但是我应该如何从外部应用程序访问?
现在我只是想使用常规Java类来测试连接,但我应该使用什么地址?我尝试使用 boot2docker ip ,但这不起作用。我也尝试使用 docker inspect 命令获得的ip,但我没有得到任何结果。
[
{
"Id": "ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16",
"Created": "2015-08-11T16:07:44.597618319Z",
"Path": "/entrypoint.sh",
"Args": [
"mysqld"
],
"State": {
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 2167,
"ExitCode": 0,
"Error": "",
"StartedAt": "2015-08-11T16:38:38.256276665Z",
"FinishedAt": "2015-08-11T16:38:08.508576127Z"
},
"Image": "a128139aadf282a10ec937a60010f837fa1b91dd367e05c7ca6197a84b3115b3",
"NetworkSettings": {
"Bridge": "",
"EndpointID": "a6e0a25891c065dc47b9dccb19c89e0ab7ee358a2b7cf947f6385bb47b99bac4",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"HairpinMode": false,
"IPAddress": "172.17.0.5",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:05",
"NetworkID": "5c8e21999516c552412027ab316d3a8d8d813952fb207c1de9ec38040895fc50",
"PortMapping": null,
"Ports": {
"3306/tcp": null
},
"SandboxKey": "/var/run/docker/netns/ee02d1e46305",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null
},
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16/ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16-json.log",
"Name": "/fluxtream",
"RestartCount": 0,
"Driver": "aufs",
"ExecDriver": "native-0.2",
"MountLabel": "",
"ProcessLabel": "",
"Volumes": {
"/var/lib/mysql": "/mnt/sda1/var/lib/docker/volumes/5a05900d9551d22235e51a7d03a7354156fce1bdea3e7378f52df8d33fee1f4f/_data"
},
"VolumesRW": {
"/var/lib/mysql": true
},
"AppArmorProfile": "",
"ExecIDs": [
"8fd70881d9cfed795dfb6850d513e54490432fd1e55e8bf8f6040f71cc1e7a4c",
"d3ca3e35de0222127c7e5da3e6ab45157cb06f5716c0c2bbfdc9a7096230786d",
"b75620585c02840a62169bc5adf0a5a80fa265194ac74136c54dc31cf9edd653",
"a61e680448ad796b1ad113776c5ba46f3b8a03f6601d843b005722748c9d5669"
],
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemorySwap": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": null,
"DnsSearch": null,
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "bridge",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": ""
},
"Config": {
"Hostname": "ee02d1e46305",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"PortSpecs": null,
"ExposedPorts": {
"3306/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_ROOT_PASSWORD=fluxtream",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"MYSQL_MAJOR=5.6",
"MYSQL_VERSION=5.6.26"
],
"Cmd": [
"mysqld"
],
"Image": "mysql:5.6.26",
"Volumes": {
"/var/lib/mysql": {}
},
"VolumeDriver": "",
"WorkingDir": "",
"Entrypoint": [
"/entrypoint.sh"
],
"NetworkDisabled": false,
"MacAddress": "",
"OnBuild": null,
"Labels": {}
}
}
]
我的开发环境:
答案 0 :(得分:2)
对我来说有用的是在创建容器时映射端口。
offset[]
0: 530332809
1: 2686632
2: 1971058176
3:0