I’m trying to run wordpress using two containers.
There are many tutorials out there. I’ve used this one: https://www.hostinger.com/tutorials/run-docker-wordpress
For some reason WordPress container can’t communicate with the mysql container.
going to localhost:8000 I get this message:
Error establishing a database connection
I thought that’s why we have docker0 (for communication between containers) but a new bridge network is always being created (should it be created?) when running docker-compose…
I’ll appreciate any assistance.
Some additional info:
docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2bb0b6311f4e wordpress:latest “docker-entrypoint.s…” About an hour ago Up About an hour 0.0.0.0:8000->80/tcp wordpress3_wordpress_1
6b3b81afd103 mysql:5.7 “docker-entrypoint.s…” About an hour ago Up About an hour 3306/tcp, 33060/tcp wordpress3_db_1
docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ 2bb0b6311f4e
172.18.0.3
docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ 6b3b81afd103
172.18.0.2
**SQL is accessible from host **
telnet 172.18.0.2 3306
Trying 172.18.0.2…
Connected to 172.18.0.2.
Escape character is ‘^]’.
WordPress is accessible from host
telnet 172.18.0.3 80
Trying 172.18.0.3…
Connected to 172.18.0.3.
Escape character is ‘^]’.
ifconfig
br-b9e08cdbb0cb: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
inet6 fe80::42:8fff:fe15:91a prefixlen 64 scopeid 0x20
ether 02:42:8f:15:09:1a txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::42:7ff:feab:7267 prefixlen 64 scopeid 0x20
ether 02:42:07:ab:72:67 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9 bytes 612 (612.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0enp7s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether f8:75:a4:31:51:b1 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 23 bytes 10606 (10.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 23 bytes 10606 (10.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0veth1dfb2aa: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::4463:2ff:fe62:a0b4 prefixlen 64 scopeid 0x20
ether 46:63:02:62:a0:b4 txqueuelen 0 (Ethernet)
RX packets 42 bytes 8728 (8.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 272 bytes 47062 (45.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0vethbc11a6b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::fc02:61ff:feb7:c59e prefixlen 64 scopeid 0x20
ether fe:02:61:b7:c5:9e txqueuelen 0 (Ethernet)
RX packets 13 bytes 909 (909.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 248 bytes 42148 (41.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.20.133 netmask 255.255.255.0 broadcast 192.168.20.255
inet6 fe80::87c9:de80:d5c4:e35b prefixlen 64 scopeid 0x20
ether 4c:1d:96:05:98:1c txqueuelen 1000 (Ethernet)
RX packets 486776 bytes 494587671 (471.6 MiB)
RX errors 0 dropped 216 overruns 0 frame 0
TX packets 187466 bytes 32715850 (31.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.20.254 0.0.0.0 UG 0 0 0 wlp0s20f3
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-b9e08cdbb0cb
192.168.20.0 0.0.0.0 255.255.255.0 U 0 0 0 wlp0s20f3
docker network ls
NETWORK ID NAME DRIVER SCOPE
82b5f6ce9037 bridge bridge local
b13c58426fa4 host host local
141d06d6193a none null local
b9e08cdbb0cb wordpress3_default bridge local