srl-labs / containerlab

container-based networking labs
https://containerlab.dev
BSD 3-Clause "New" or "Revised" License
1.54k stars 263 forks source link

Nodes' binds option mounts folders with uid of user instead of the root #2196

Closed mdahshan closed 1 month ago

mdahshan commented 1 month ago

Hi Team,

I am having an issue with the bind option for the node kind.

For the following topology:

    ftpserver:
      kind: linux
      image: ftpserver:latest
      group: server        
      binds:
        - ./vsftpd.conf:/etc/vsftpd/vsftpd.conf

When deploying the topology, the file vsftpd.conf has owner:group as 1000:1000 instead of the root. This breaks the functionality of the vsftpd as it refuses to start due to incorrect owner.

This problem only happens on the amd64 version. The arm64 version mounts correctly with root ownership.

Containerlab version:

version: 0.57.2
 commit: a6b1f044
   date: 2024-09-16T14:12:31Z

The Dockerfile for ftpservers looks as follows:

FROM alpine:latest
RUN apk add --no-cache vsftpd

EXPOSE 20 21

RUN rm -rf /var/cache/apk/*

ENTRYPOINT ["vsftpd", "/etc/vsftpd/vsftpd.conf"]

Thanks for your help

hellt commented 1 month ago

Hi what are the original permissions on the ./vsftpd.conf in your directory?

ls -la vsftpd.conf
mdahshan commented 1 month ago

The permissions in both machines are:

-rw-r--r--   1 mostafa mostafa    88 Sep 19 10:31 vsftpd.conf

$ echo $UID
1000

Both machines are running Debian 12. The one that works fine is running on UTM on Apple Silicon.

$ docker exec clab-netfor3-ftpserver ls -l /etc/vsftpd/
total 4
-rw-r--r--    1 root     root            88 Sep 19 00:31 vsftpd.conf

The second one is on lib-virt on amd64. I also tested on Ubuntu 24.04 and I encountered the same issue. The ftpserver container refuses to start. When I changed the startup command and listed the directory content, I got 1000 1000 as owner and group.

hellt commented 1 month ago

your uid/gid is 1000, docker mounts the files with the same permissions you can

This is not something that containerlab controls.

mdahshan commented 1 month ago

Thanks for your help. I will do that.