containers / containers/podlet

There are some network issues with multi-container pods generated from compose

Open
#137 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.6k
Forks
48
Avg merge
1d 9h
Merged PRs (30d)
1

Description

```
# compose.yaml
name: n8n
services:
postgres:
image: docker.io/library/postgres:16
restart: unless-stopped
environment:
- POSTGRES_USER=changeUser
- POSTGRES_PASSWORD=changePassword
- POSTGRES_DB=n8n
- POSTGRES_NON_ROOT_USER=changeUser
- POSTGRES_NON_ROOT_PASSWORD=changePassword
volumes:
- ./db_storage:/var/lib/postgresql/data
- ./init-data.sh:/docker-entrypoint-initdb.d/init-data.sh
healthcheck:
test: ["CMD-SHELL", "pg_isready -h localhost -U changeUser -d n8n"]
interval: 5s
timeout: 5s
retries: 10
labels:
- "io.containers.autoupdate=registry"
networks:
- n8n_network

n8n:
image: docker.n8n.io/n8nio/n8n
restart: unless-stopped
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=systemd-n8n-postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=n8n
- DB_POSTGRESDB_USER=changeUser
- DB_POSTGRESDB_PASSWORD=changePassword
ports:
- 5678:5678
volumes:
- ./n8n_storage:/home/node/.n8n
depends_on:
- postgres
labels:
- "io.containers.autoupdate=registry"
networks:
- n8n_network

networks:
n8n_network:
driver: bridge

```

I generate quadlet files from this compose, and get

```
# n8n-postgres.container
[Container]
AutoUpdate=registry
Environment=POSTGRES_USER=changeUser POSTGRES_PASSWORD=changePassword POSTGRES_DB=n8n POSTGRES_NON_ROOT_USER=changeUser POSTGRES_NON_ROOT_PASSWORD=changePassword
HealthCmd=pg_isready -h localhost -U changeUser -d n8n
HealthInterval=5s
HealthRetries=10
HealthTimeout=5s
Image=docker.io/library/postgres:16
Network=n8n_network.network
Pod=n8n.pod
Volume=/home/nite/Downloads/pod/n8n/db_storage:/var/lib/postgresql/data
Volume=/home/nite/Downloads/pod/n8n/init-data.sh:/docker-entrypoint-initdb.d/init-data.sh

[Service]
Restart=always

[Install]
WantedBy=default.target

---

# n8n-n8n.container
[Unit]
Requires=n8n-postgres.service
After=n8n-postgres.service

[Container]
AutoUpdate=registry
Environment=DB_TYPE=postgresdb DB_POSTGRESDB_HOST=systemd-n8n-postgres DB_POSTGRESDB_PORT=5432 DB_POSTGRESDB_DATABASE=n8n DB_POSTGRESDB_USER=changeUser DB_POSTGRESDB_PASSWORD=changePassword
Image=docker.n8n.io/n8nio/n8n
Network=n8n_network.network
Pod=n8n.pod
Volume=/home/nite/Downloads/pod/n8n/n8n_storage:/home/node/.n8n

[Service]
Restart=always

[Install]
WantedBy=default.target

---

# n8n_network.network
[Network]
Driver=bridge

[Install]
WantedBy=default.target

---

# n8n.pod
[Pod]
PublishPort=5678:5678

[Install]
WantedBy=default.target
```

I found that I could not access n8n from the host through 5678. At this time, the host port listening status was

```
❯ lsof -i :5678
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
passt.avx 712691 nite 6u IPv6 2928872 0t0 TCP *:rrac (LISTEN)
```

When I removed `PublishPort=5678:5678` from the .pod file and added it to n8n-n8n.container, the problem was solved.

```
# n8n-n8n.container
[Unit]
Requires=n8n-postgres.service
After=n8n-postgres.service

[Container]
AutoUpdate=registry
Environment=DB_TYPE=postgresdb DB_POSTGRESDB_HOST=systemd-n8n-postgres DB_POSTGRESDB_PORT=5432 DB_POSTGRESDB_DATABASE=n8n DB_POSTGRESDB_USER=changeUser DB_POSTGRESDB_PASSWORD=changePassword
Image=docker.n8n.io/n8nio/n8n
Network=n8n_network.network
Pod=n8n.pod
Volume=/home/nite/Downloads/pod/n8n/n8n_storage:/home/node/.n8n
PublishPort=5678:5678

[Service]
Restart=always

[Install]
WantedBy=default.target

---
#n8n.pod
[Pod]

[Install]
WantedBy=default.target
```

At this time, the host port listening status is

```
❯ lsof -i:5678
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rootlessp 740334 nite 10u IPv6 3040438 0t0 TCP \*:rrac (LISTEN)

```

Is this as expected or a bug?

In addition, I found that a container in a compose file connect to another container not using the name of the container in the compose file. For example, in this compose file, the n8n container connect to the postgres container through `systemd-n8n-postgres`. If using `postgres`, a dns error will be obtained. This is a bit confusing.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.