Usando o CoreOS (docker pré-instalado), não consigo fazer com que dois contêineres se comuniquem juntos.
Estou tentando configurar um contêiner MySql chamado por um contêiner Gogs (servidor Git).
Então, aqui está o que eu fiz:
A porta é configurada com 127.0.0.1, portanto, não pode ser acessível de fora.
docker run --name mysql1 -v /volumedata/mysql/mysql1:/var/lib/mysql -e
MYSQL_ROOT_PASSWORD=PWDHERE -p 127.0.0.1:33061:3306 -d
mysql/mysql-server:latest --character-set-server=utf8
--collation-server=utf8_general_ci
E então eu instalei
docker run --name=go-git-server1 -p 10022:22 -p 10080:3000 -v
/data/go-git-server1:/data gogs/gogs
Ambos estão em execução quando eu verifico com docker ps -a e posso acessar a página de instalação de "go-git-server1" sem nenhum problema, no entanto, quando eu especificar o host endereço:
127.0.0.1:33061
na página de configuração do Gogs, depois de validar, eu tenho este erro:
Database setting is not correct: dial tcp 127.0.0.1:33061: getsockopt: connection refused
Eu pensei que com o IP e Porta dados por "docker ps -a" (e já definidos manualmente com o "docker run" inicial) teria sido suficiente para o contêiner "go-git-server1" acessar o MySql banco de dados.
Estou faltando um passo?
Há algo mais que precisamos fazer para que o contêiner MySql possa ser acessado a partir do outro contêiner?
Aqui está o que a janela de encaixe inspeciona o mysql1:
docker inspect mysql1
[
{
"Id": "c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166",
"Created": "2016-07-03T21:55:29.693884299Z",
"Path": "/entrypoint.sh",
"Args": [
"-p",
"127.0.0.1:33061:3306"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 1,
"Error": "",
"StartedAt": "2016-07-26T18:23:36.144915853Z",
"FinishedAt": "2016-07-26T18:23:38.281589339Z"
},
"Image": "4e66d61404cc06e3c40c46f5e83bda5a14dda2838b84210c7eb5a3d6e1f7752b",
"ResolvConfPath": "/var/lib/docker/containers/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/hostname",
"HostsPath": "/var/lib/docker/containers/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/hosts",
"LogPath": "/var/lib/docker/containers/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166-json.log",
"Name": "/mysql1",
"RestartCount": 0,
"Driver": "overlay",
"ExecDriver": "native-0.2",
"MountLabel": "system_u:object_r:svirt_lxc_file_t:s0:c724,c935",
"ProcessLabel": "system_u:system_r:svirt_lxc_net_t:s0:c724,c935",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/donnees/mysql/mysql1:/var/lib/mysql"
],
"ContainerIDFile": "",
"LxcConf": [],
"Memory": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"KernelMemory": 0,
"CpuShares": 0,
"CpuPeriod": 0,
"CpusetCpus": "",
"CpusetMems": "",
"CpuQuota": 0,
"BlkioWeight": 0,
"OomKillDisable": false,
"MemorySwappiness": -1,
"Privileged": false,
"PortBindings": {},
"Links": null,
"PublishAllPorts": false,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"VolumesFrom": null,
"Devices": [],
"NetworkMode": "default",
"IpcMode": "",
"PidMode": "",
"UTSMode": "",
"CapAdd": null,
"CapDrop": null,
"GroupAdd": null,
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"SecurityOpt": null,
"ReadonlyRootfs": false,
"Ulimits": null,
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"CgroupParent": "",
"ConsoleSize": [
0,
0
],
"VolumeDriver": ""
},
"GraphDriver": {
"Name": "overlay",
"Data": {
"LowerDir": "/var/lib/docker/overlay/4e66d61404cc06e3c40c46f5e83bda5a14dda2838b84210c7eb5a3d6e1f7752b/root",
"MergedDir": "/var/lib/docker/overlay/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/merged",
"UpperDir": "/var/lib/docker/overlay/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/upper",
"WorkDir": "/var/lib/docker/overlay/c811d29d866ef977eb0cb93a9697bc4afd2a51e828b7757a5ea8962d784f0166/work"
}
},
"Mounts": [
{
"Source": "/donnees/mysql/mysql1",
"Destination": "/var/lib/mysql",
"Mode": "",
"RW": true
}
],
"Config": {
"Hostname": "c811d29d866e",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_ROOT_PASSWORD=mypwd",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"PACKAGE_URL=https://repo.mysql.com/yum/mysql-5.7-community/docker/x86_64/mysql-community-server-minimal-5.7.13-1.el7.x86_64.rpm"
],
"Cmd": [
"-p",
"127.0.0.1:33061:3306"
],
"Image": "mysql/mysql-server:latest",
"Volumes": {
"/var/lib/mysql": {}
},
"WorkingDir": "",
"Entrypoint": [
"/entrypoint.sh"
],
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGTERM"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": null,
"SandboxKey": "",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": ""
}
}
}
}
]
Eu tentei o ip dado por
ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+'
... em vez disso, o 127.0.0.1 falhou, mas não, não funciona.
Parece que estou preso no primeiro passo da comunicação do contêiner do Docker.