Autor Zpráva
breeta
Profil
Zdravím, zkouším rozjet docker přes phpdocker.io s nastavením viz níže. Doker mě běží na IP 192.168.99.100

Když hodím testovací soubor na připojení:

$servername = "192.168.99.100";
$username = "test";
$password = "test";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";

Tak se nepřipojí: Connection failed: Connection refused

Nevíte ke může být chyba?

S pozdravem

version: "3.1"
services:

mysql:
image: mysql:8.0
container_name: test-mysql
working_dir: /application
volumes:
- .:/application
environment:
- MYSQL_ROOT_PASSWORD=test
- MYSQL_DATABASE=test
- MYSQL_USER=test
- MYSQL_PASSWORD=test
ports:
- "1027:3306"

webserver:
image: nginx:alpine
container_name: test-webserver
working_dir: /application
volumes:
- .:/application
- ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "1025:80"

php-fpm:
build: phpdocker/php-fpm
container_name: test-php-fpm
working_dir: /application
volumes:
- .:/application
- ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php/7.2/fpm/conf.d/99-overrides.ini
Kajman
Profil
Pokud se chcete připojit k mysql z jiného stroje v rámci lokální sítě, mrkněte v konfiguraci mysql na
dev.mysql.com/doc/refman/5.7/en/server-options.html#option_mysqld_bind-address
breeta
Profil
Kajman:

Nějak na to nemůžu dojít, vyjel sem inspect ...


$ docker inspect test-mysql
[
    {
        "Id": "9967738f93a46be9c657a6f9cff294cf45b97feed87cb4a18bc0a5d5323869a7",
        "Created": "2018-03-19T12:52:40.446098772Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "mysqld"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 16738,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-03-19T12:52:41.068203197Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:96dd4fed435959a0df283c97076ea08771322bdb02a981c20ee242993ce9de78",
        "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/9967738f93a46be9c657a6f9cff294cf45b97feed87cb4a18bc0a5d5323869a7/resolv.conf",
        "HostnamePath": "/mnt/sda1/var/lib/docker/containers/9967738f93a46be9c657a6f9cff294cf45b97feed87cb4a18bc0a5d5323869a7/hostname",
        "HostsPath": "/mnt/sda1/var/lib/docker/containers/9967738f93a46be9c657a6f9cff294cf45b97feed87cb4a18bc0a5d5323869a7/hosts",
        "LogPath": "/mnt/sda1/var/lib/docker/containers/9967738f93a46be9c657a6f9cff294cf45b97feed87cb4a18bc0a5d5323869a7/9967738f93a46be9c657a6f9cff294cf45b97feed87cb4a18bc0a5d5323869a7-json.log",
        "Name": "/test-mysql",
        "RestartCount": 0,
        "Driver": "aufs",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "12c5f8281551f6b7386bb6658e546ac0688f17c31bc55d3101d740186563a19d:/var/lib/mysql:rw",
                "/c/Users/OEM/test.cz:/application:rw"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "testcz_default",
            "PortBindings": {
                "3306/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "1027"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": [],
            "CapAdd": null,
            "CapDrop": null,
            "Dns": null,
            "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
        },
        "GraphDriver": {
            "Data": null,
            "Name": "aufs"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "12c5f8281551f6b7386bb6658e546ac0688f17c31bc55d3101d740186563a19d",
                "Source": "/mnt/sda1/var/lib/docker/volumes/12c5f8281551f6b7386bb6658e546ac0688f17c31bc55d3101d740186563a19d/_data",
                "Destination": "/var/lib/mysql",
                "Driver": "local",
                "Mode": "rw",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "bind",
                "Source": "/c/Users/OEM/test.cz",
                "Destination": "/application",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "9967738f93a4",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "3306/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "MYSQL_ROOT_PASSWORD=test",
                "MYSQL_PASSWORD=test",
                "MYSQL_USER=test",
                "MYSQL_DATABASE=test",
                "affinity:container==4e98b3c73fcc0d8cfbbfc72cd51d2d1c10790301857962e32bf8539e962c2b4e",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "GOSU_VERSION=1.7",
                "MYSQL_MAJOR=8.0",
                "MYSQL_VERSION=8.0.4-rc-1debian9"
            ],
            "Cmd": [
                "mysqld"
            ],
            "ArgsEscaped": true,
            "Image": "mysql:8.0",
            "Volumes": {
                "/application": {},
                "/var/lib/mysql": {}
            },
            "WorkingDir": "/application",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "com.docker.compose.config-hash": "04338cbdee25c2b7f877e5f0bcd70f6d6bbeae0965a9957b0d134ae2e923a38b",
                "com.docker.compose.container-number": "1",
                "com.docker.compose.oneoff": "False",
                "com.docker.compose.project": "testcz",
                "com.docker.compose.service": "db",
                "com.docker.compose.version": "1.19.0"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "e26d0cd838124b9afda49f123762794867b5a80581012ec65fbc07db2460c791",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "3306/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "1027"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/e26d0cd83812",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "testcz_default": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": [
                        "9967738f93a4",
                        "db"
                    ],
                    "NetworkID": "f5318e80343243ef770de6b0ecebfcbeb75b596c7a9bbc0c22a4135c6f128e23",
                    "EndpointID": "feae679bc88f829331cbc489161976a87775a02e15f90cfb365c60ef83f859ad",
                    "Gateway": "172.19.0.1",
                    "IPAddress": "172.19.0.5",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:13:00:05",
                    "DriverOpts": null
                }
            }
        }
    }
]


Moderátor juriad: Odmazal jsem několik kopií inspectu.

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: