How to access a mysql database that is into a Docker continer?

I’m working in a windows environment and I have my MySQL database into a Docker container, but how I should access from an external application?

Right now I’m just want to use a regular Java Class to test the connection but what address should I use? I’ve tried with the boot2docker ip, but that doesn’t work. I’ve also tried with the ip that I got with the docker inspect command but I haven’t got any result.

  • How to use the rabbitmq docker compose yml file to build docker image?
  • kafka-node LeaderNotAvailable errors on send
  • Dockerfile: create ENV variable that a USER can see?
  • Kubernetes container connection to RDS instance in separate VPC
  • How to perform checkpoint and restore of docker containers across two hosts?
  • What does --net=host option in Docker command really do?
  • [
        "Id": "ee02d1e463056c8dcd878fa7d9746c39b4377e051d11a8853be274b206b73c16",
        "Created": "2015-08-11T16:07:44.597618319Z",
        "Path": "/",
        "Args": [
        "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": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "HairpinMode": false,
            "IPAddress": "",
            "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": [
        "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": [
            "Cmd": [
            "Image": "mysql:5.6.26",
            "Volumes": {
                "/var/lib/mysql": {}
            "VolumeDriver": "",
            "WorkingDir": "",
            "Entrypoint": [
            "NetworkDisabled": false,
            "MacAddress": "",
            "OnBuild": null,
            "Labels": {}

    My dev enviroment:

    • Windows 7 Pro
    • Docker 1.7.0
    • Boot2Docker-cli version 1.7.0
    • MySQL container 5.6.26

  • Update cURL php extension on php:7.0-fpm docker container
  • Fail to install Starman inside Docker container
  • Bcrypt: invalid ELF header with Docker and Sails.JS
  • How to start Docker daemon inside a Docker container using supervisord?
  • Returning host IP address into docker contain inside systemd configuration file
  • Difference between environment in Dockerfile RUN and interactive shell on a running container?
  • One Solution collect form web for “How to access a mysql database that is into a Docker continer?”

    What worked for my is mapping the port when I created the container.

    docker run --name YOUR_CONTAINER -p 3306:3306 -e MYSQL_ROOT_PASSWORD=YOUR_PASS -d mysql:5.6.26
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.