Docker Community Forums

Share and learn in the Docker community.

Unable to resolve container name in docker-compose when creating volume

I am trying to map int a container an nfs volume created by another container, docker-compose.yml

version: '3.8'
services:
    nfs:
        image: erichough/nfs-server
        restart: unless-stopped
        volumes:
            - ./data:/share/data0
        environment:
            - NFS_EXPORT_0='/share/data0                  *(rw,no_subtree_check)'
    proxy:
        image: nginx
        restart: unless-stopped
        depends_on:
            - nfs
        ports:
          - '80:80'
          - '443:443'
        volumes:
           - share0:/mnt
volumes:
    share0:
      driver_opts:
        type: "nfs"
        o: "addr=nfs,nolock,soft,rw"
        device: ":/share/data0"

Curretnly I am receiving this error:

Creating ehough_nfs_1 ... done
Creating ehough_proxy_1 ... error

ERROR: for ehough_proxy_1  Cannot create container for service proxy: error resolving passed in network volume address: lookup nfs on 127.0.0.53:53: read udp 127.0.0.1:48081->127.0.0.53:53: i/o timeout

ERROR: for proxy  Cannot create container for service proxy: error resolving passed in network volume address: lookup nfs on 127.0.0.53:53: read udp 127.0.0.1:48081->127.0.0.53:53: i/o timeout
ERROR: Encountered errors while bringing up the project.

Any suggestion?
Thanks

I used volumes: to work around this problem. In your case:

version: ‘2’
services:
test.base:
container_name: test.base
image: docker.pnet.ch/r-base:latest
restart: on-failure
networks:
- mynet
volumes:
- ./resolv.conf:/etc/resolv.conf
Where the ./resolv.conf file contains what exactly you expected as:

search pext.ch pnet.ch
nameserver 192.168.198.2
Here assumes the resolv.conf file is on the same folder as your docker-compose file.

I am wondering if there is another option because it can happen that I don’t know the ip of the first container is going to start