Answer the question
In order to leave comments, you need to log in
Why don't docker containers see each other by name?
Hello everyone, I can not understand why the containers do not see each other by name.
Oracle Linux 8
Docker Compose version v2.2.3
Podman version 3.3.1
Runs through Docker Compose.
version: "3.7"
services:
php:
container_name: unit
image: unit:1.26.1
ports:
- "8080:8080"
volumes:
- ./www/:/var/www/
restart: unless-stopped
hostname: hostname-unit
web:
container_name: nginx
image: nginx:1.21.5
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/:/etc/nginx/
links:
- php:unit
restart: unless-stopped
hostname: hostname-nginx
#podman inspect nginx -f "{{json .NetworkSettings.Networks }}"
{
"stack_default": {
"EndpointID": "",
"Gateway": "10.89.2.1",
"IPAddress": "10.89.2.4",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "c6:be:a4:e2:d3:6a",
"NetworkID": "stack_default",
"DriverOpts": null,
"IPAMConfig": null,
"Links": null,
"Aliases": ["nginx", "web"]
}
}
#podman inspect unit -f "{{json .NetworkSettings.Networks }}"
{
"stack_default": {
"EndpointID": "",
"Gateway": "10.89.2.1",
"IPAddress": "10.89.2.5",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "62:fd:bc:17:87:7b",
"NetworkID": "stack_default",
"DriverOpts": null,
"IPAMConfig": null,
"Links": null,
"Aliases": ["php", "unit"]
}
}
#podman exec -ti nginx
/ # ping php
ping: bad address 'php'
/ # ping unit
ping: bad address 'unit'
/ # ping 10.89.2.5
PING 10.89.2.5 (10.89.2.5): 56 data bytes
64 bytes from 10.89.2.5: seq=0 ttl=64 time=0.070 ms
64 bytes from 10.89.2.5: seq=1 ttl=64 time=0.083 ms
64 bytes from 10.89.2.5: seq=2 ttl=64 time=0.069 ms
64 bytes from 10.89.2.5: seq=3 ttl=64 time=0.080 ms
/ # cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
10.89.2.4 hostname-nginx nginx
10.89.2.1 host.containers.internal
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
10.89.2.5 hostname-unit unit
10.89.2.1 host.containers.internal
# podman network inspect stack_default
[
{
"args": {
"podman_labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "stack",
"com.docker.compose.version": "2.2.3"
}
},
"cniVersion": "0.4.0",
"name": "stack_default",
"plugins": [
{
"bridge": "cni-podman3",
"hairpinMode": true,
"ipMasq": true,
"ipam": {
"ranges": [
[
{
"gateway": "10.89.2.1",
"subnet": "10.89.2.0/24"
}
]
],
"routes": [
{
"dst": "0.0.0.0/0"
}
],
"type": "host-local"
},
"isGateway": true,
"type": "bridge"
},
{
"capabilities": {
"portMappings": true
},
"type": "portmap"
},
{
"backend": "",
"type": "firewall"
},
{
"type": "tuning"
}
]
}
]
#podman inspect container_name -f "{{json .NetworkSettings.Networks }}"
#podman network inspect network_name
Answer the question
In order to leave comments, you need to log in
The solution has been found.
I will leave it for posterity.
Still, podman != docker
Therefore, to solve the problem, you need to put dnsname (part of podman-plugins or build) and dnsmasq.
And further in the text .
I also installed podman-compose, but it was no use :)
Thank you all for your attention.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question