containers / containers/podman-compose
hostname is not listed in /etc/hosts
- Dominant language
- Python
- Stars
- 6.2k
- Forks
- 622
- PR merge metrics
- No merged PRs in 30d
Description
When I start a simple compose file like
```
version: "3.7"
services:
metadb:
image: postgres:latest
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
```
it generates the following podman call to generate the container:
```
podman run --name=podman-compose-test_metadb_1 -d --pod=podman-compose-test --label io.podman.compose.config-hash=123 --label io.podman.compose.project=podman-compose-test --label io.podman.compose.version=0.0.1 --label com.docker.compose.container-number=1 --label com.docker.compose.service=metadb --add-host metadb:127.0.0.1 --add-host podman-compose-test_metadb_1:127.0.0.1 postgres:latest
```
This results in a random hostname in /etc/hosts and that hostname not listed in /etc/hosts.
When I run the command without attaching the container in a pod, the hostname is included in /etc/hosts as expected.
I don't know if this is a bug in podman when attaching containers to pods, or podman-compose not setting the hostname of the container (`--hostname`) to the name that is also included in the /etc/hosts file. I think both places would be good to fix this.
I would recommend as a quick fix to just add `--hostname=${SERVICE_NAME}` to the podman call, so that /etc/hosts and /etc/hostname are matching.
Version Info:
```
> podman-compose version
using podman version: podman version 1.8.3-dev
podman-composer version 0.1.7dev
podman --version
podman version 1.8.3-dev
0
```
Contributor guide
Assessment
This issue has not been assessed yet.