Docker在Localhost中的数据库查询(在RDS中)非常慢,但是在EC2实例中非常快

时间:2019-06-10 00:40:26

标签: database amazon-web-services docker dns local

我使用远程数据库(Amazon RDS)。 当我在本地环境中运行Docker时,数据库中的查询会花费很多时间(10个选择几乎需要1分钟)。 但是,当我在EC2服务器(亚马逊云服务器)中运行它时,它的运行环境完全相同,运行速度非常快,没有出现问题。 我想这是DNS解析的问题。

我尝试用我看到的建议更改主机文件和resolv.conf文件,但是什么也没有。

检查Docker映像

[
    {
        "Id": "ab372c272d41965abb2fc5583905a659744f60c310580ca96d3e745e10cb407d",
        "Created": "2019-06-09T23:53:02.419158394Z",
        "Path": "docker-php-entrypoint",
        "Args": [
            "apache2-foreground"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 47725,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-06-09T23:53:03.650942252Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:5afca910ec01f30607d72c4550ba438228f0895cd81535b7ae7b94de43ec8f87",
        "ResolvConfPath": "/var/lib/docker/containers/ab372c272d41965abb2fc5583905a659744f60c310580ca96d3e745e10cb407d/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/ab372c272d41965abb2fc5583905a659744f60c310580ca96d3e745e10cb407d/hostname",
        "HostsPath": "/var/lib/docker/containers/ab372c272d41965abb2fc5583905a659744f60c310580ca96d3e745e10cb407d/hosts",
        "LogPath": "/var/lib/docker/containers/ab372c272d41965abb2fc5583905a659744f60c310580ca96d3e745e10cb407d/ab372c272d41965abb2fc5583905a659744f60c310580ca96d3e745e10cb407d-json.log",
        "Name": "/Local",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/Users/aggelosdiamantopoulos/Desktop/opencart_project:/var/www/html:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "80"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [
                "8.8.8.8",
                "192.168.1.254"
            ],
            "DnsOptions": null,
            "DnsSearch": null,
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": null,
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": null,
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/be2991dbb15d77347a486ac0fddb81f5a0fec058e89f42bc90b511e99ac14ffb-init/diff:/var/lib/docker/overlay2/3729eb77bc45d9b828b172db9d2573ea1ca9e1918c07970c3a6b65641bbe73ba/diff:/var/lib/docker/overlay2/3bf5dc3d3acaada84ccdd6b72956f27cf1b87d979c4deaebd034862589a93af7/diff:/var/lib/docker/overlay2/e48ff871900246fc850dc18d8d75a4e6642ff7114ea93b22b83d5db4203946df/diff:/var/lib/docker/overlay2/ef8d53849f61ef56b76032147740727d5d0a9d7dd00cdf09fa155cf68b8e890c/diff:/var/lib/docker/overlay2/445aa18980fffbf79c478ecf6c302360fe21e3ee9fa80de2ecb6ce8afe0fd82f/diff:/var/lib/docker/overlay2/078ebcba60eebc752862fadaad529088bd8599b065ad3b1865dfa3791315c43f/diff:/var/lib/docker/overlay2/526f8158882a1303cc0164c9c08988acd9d1a31a4d019d7560ee01eca4006d17/diff:/var/lib/docker/overlay2/d0bd25271fe1b09b766779509b65299d36b40c4dd9c8e9bdf895ac812ee07afc/diff:/var/lib/docker/overlay2/666fd0f8b6328c2796079dece68a90b67061207667619e231629b5e57f44f4d2/diff:/var/lib/docker/overlay2/7e6bcce0736c3e5b65cc67af91a8d1e0b09d2c90ae7dbf5e3d1467f5ee7d421d/diff:/var/lib/docker/overlay2/163911f12b985b7459099b88aef93870a2ad42dda403bbae8e30f127683ed786/diff:/var/lib/docker/overlay2/1efed71979dc4e5e2c3915e166ecc64f1f30e60c42cb26606f36ff901b16fc52/diff:/var/lib/docker/overlay2/ed47977f4208ece1aee1823cb784b7843d9e1819fbe7bc0493499186816a026f/diff:/var/lib/docker/overlay2/7f5ac95f3df1a5bb504aef70edee11153215408f2e450af9d1de6fe893248971/diff:/var/lib/docker/overlay2/e7020b87b127b46633ed8317d40e76134bc814ca4c352a33305585b4458c71bc/diff:/var/lib/docker/overlay2/77f21fc32116c467146cef7728542831c5b8ace95170457362c8a4ddae571655/diff:/var/lib/docker/overlay2/d1199a21ee7f35a0d43a60536529ecfe4dfb7d79e23bd38d593d3ef292acaa6e/diff:/var/lib/docker/overlay2/3c02894019060782bbd2cfeee96e3d2fb48dbf56de14c9b332944b5e4b152695/diff:/var/lib/docker/overlay2/07debd09817c11cd3a1023e111be35fc965974d88b6251479ec80ee715d6c646/diff:/var/lib/docker/overlay2/8e4f77bf1dc4490d2234155840fab3fd28366c71f1e399ca160e2bbb4e87b28a/diff:/var/lib/docker/overlay2/0c0661c24debd7dc06cc188af9e52779b0bd73d72e3dd9963eca5851d641fd2f/diff:/var/lib/docker/overlay2/1191ee3eed14f3884d3c26e7914a6b9b9a2cb3739dc8fbd786bf2f0983a05b01/diff:/var/lib/docker/overlay2/d94d6bf467ad9be1b47fab3f95e5c8add4eccdc3848d9252a7fcbbdd1b3d33e3/diff:/var/lib/docker/overlay2/22efd78192a2efab9337d9dcb91b34e154661124a657d8cf276f9caeccfee698/diff:/var/lib/docker/overlay2/769aaa8fc55c7f087a7581646881d5fa6a901f28fe63a3d5adfd0c993971b57e/diff:/var/lib/docker/overlay2/81ea65735be7db4f2069b9ff0d1ada6c87ca5d845866503fa0e3bc8ddabba222/diff:/var/lib/docker/overlay2/317848078deba0afad1568ff08ebaafd439325cd804f9a1c08e252e6f154126f/diff",
                "MergedDir": "/var/lib/docker/overlay2/be2991dbb15d77347a486ac0fddb81f5a0fec058e89f42bc90b511e99ac14ffb/merged",
                "UpperDir": "/var/lib/docker/overlay2/be2991dbb15d77347a486ac0fddb81f5a0fec058e89f42bc90b511e99ac14ffb/diff",
                "WorkDir": "/var/lib/docker/overlay2/be2991dbb15d77347a486ac0fddb81f5a0fec058e89f42bc90b511e99ac14ffb/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/Users/aggelosdiamantopoulos/Desktop/opencart_project",
                "Destination": "/var/www/html",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "ab372c272d41",
            "Domainname": "",
            "User": "",
            "AttachStdin": true,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": true,
            "OpenStdin": true,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "PHPIZE_DEPS=autoconf \t\tdpkg-dev \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c",
                "PHP_INI_DIR=/usr/local/etc/php",
                "APACHE_CONFDIR=/etc/apache2",
                "APACHE_ENVVARS=/etc/apache2/envvars",
                "PHP_EXTRA_BUILD_DEPS=apache2-dev",
                "PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2 --disable-cgi",
                "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2",
                "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2",
                "PHP_LDFLAGS=-Wl,-O1 -Wl,--hash-style=both -pie",
                "GPG_KEYS=CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D",
                "PHP_VERSION=7.3.4",
                "PHP_URL=https://www.php.net/get/php-7.3.4.tar.xz/from/this/mirror",
                "PHP_ASC_URL=https://www.php.net/get/php-7.3.4.tar.xz.asc/from/this/mirror",
                "PHP_SHA256=6fe79fa1f8655f98ef6708cde8751299796d6c1e225081011f4104625b923b83",
                "PHP_MD5="
            ],
            "Cmd": [
                "apache2-foreground"
            ],
            "ArgsEscaped": true,
            "Image": "5afca910ec01",
            "Volumes": null,
            "WorkingDir": "/var/www/html",
            "Entrypoint": [
                "docker-php-entrypoint"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "db4d64d6ce24e929bf355b4799e1b4122fa1ac3468573607448baed079ef0156",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "80"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/db4d64d6ce24",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "64bdae6e7aaaae77fe420db85736e622300881bbf03e532f8b25f56de264306a",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "13ae85a8fe651627a2760650ab9aed3d6780be690f0366d908348aee03b20dcc",
                    "EndpointID": "64bdae6e7aaaae77fe420db85736e622300881bbf03e532f8b25f56de264306a",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

0 个答案:

没有答案