Hello I am trying to attach nfs volume on my podman container using podman-compose.
However, it always says mount.nfs4: Failed to resolve server : Name or service not known. How can I solve?
Environment
- podman version 4.9.4-dev
- podman-compose version 1.0.6
Reproduce problem
In my terminal (host OS), it mounts well as you can see.
$ mount -t nfs XXX.XXX.XXX.XXX:/mnt/nfs1 /mnt/nfs1
$ mount | grep nfs
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
XXX.XXX.XXX.XXX:/mnt/nfs1 on /mnt/nfs1 type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=AAA.AAA.AAA.AAA,local_lock=none,addr=XXX.XXX.XXX.XXX)
However, using podman-compose, it doesn't well.
docker-compose.yaml
version: "3"
services:
test-nfs:
image: "registry.access.redhat.com/ubi8/ubi:8.9-1136"
container_name: "test-nfs"
network_mode: "host"
privileged: true
restart: always
volumes:
- nfs1:/mnt/nfs1
volumes:
nfs1:
driver: local
driver_opts:
type: "nfs"
o: "addr=XXX.XXX.XXX.XXX"
device: ":/mnt/nfs1"
Using above file, let's run the container.
$ podman-compose -f docker-compose.yaml up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.9.4-dev
** excluding: set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=root', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
podman volume inspect root_nfs1 || podman volume create root_nfs1
['podman', 'volume', 'inspect', 'root_nfs1']
podman create --name=test-nfs --label io.podman.compose.config-hash=8c0e9bc14a626047910a2c6fa6ad4eda5b6c094c538ae3a33c19656408c35904 --label io.podman.compose.project=root --label io.podman.compose.version=1.0.6 --label [email protected] --label com.docker.compose.project=root --label com.docker.compose.project.working_dir=/root --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=test-nfs -v root_nfs1:/mnt/nfs1 --network host --privileged --restart always registry.access.redhat.com/ubi8/ubi:8.9-1136
4c0bf4295b8aac36923e78ac26136fb0a5332f989512205fbb15d7c2f173a1e2
exit code: 0
podman start -a test-nfs
Error: unable to start container 4c0bf4295b8aac36923e78ac26136fb0a5332f989512205fbb15d7c2f173a1e2: mounting volume root_nfs1 for container 4c0bf4295b8aac36923e78ac26136fb0a5332f989512205fbb15d7c2f173a1e2: mount.nfs4: Failed to resolve server : Name or service not known
exit code: 125
Question
- Is there anything I have to do for NFS mount?
- What is the reason of this problem?
I found the way what I missed.
There are two things.
If you changed your volume contents in
docker-compose.yaml, you should remove at the podman volume with commandpodman volume rm <volume_name>Don't put "addr=XXX.XXX.XXX.XXX" at "o:" (options). It doesn't work (at least in podman) Put it like
device: "XXX.XXX.XXX.XXX:/mnt/nfs1"as you did at terminal for mount.Below is my full
.yamlfile. I hope this helps you.* FYI, I also tested cephfs. It works well.
docker-compose.yaml