Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running a container with a Samba volume specified by a hostname seems to have stop working. #4816

Closed
Gwenn-LR opened this issue Jan 23, 2024 · 5 comments

Comments

@Gwenn-LR
Copy link

Gwenn-LR commented Jan 23, 2024

Description

Hi,

First of all thanks to your all your team and the community for all the work done and brought to everyone.

I'm using Docker in Docker to run CI steps with Gitlab runner and while the connection to a samba volume was working previously, it seems that the specification of a Samba volume by a hostname as described in your documentation doesn't work anymore.

It used to work smoothly 3 months ago (I have discontinued the CI worflow for a long time) and I've changed the storage volume since, so I was thinking the following error was coming from my side:

docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/< VOLUME_NAME >/_data': failed to mount local volume: mount //< SERVER_ADDR >/< DATA_DIR >:/var/lib/docker/volumes/< VOLUME_NAME >/_data, data: addr=< SERVER_HOSTNAME >,username=< USERNAME >,password=*********,file_mode=0777,dir_mode=0777: invalid argument.

However I've finally suceeded to connect my volume directly using the IP address when creating the docker volume so this issue seems to originate from the field addr since the < SERVER_HOSTNAME > < SERVER_ADDR > conversion is correct.

That's why I was wondering if this behaviour was coming from a modification of docker or if I was missing something out.

Reproduce

ISSUE

  1. docker volume create \
    --driver local
    --opt type=cifs
    --opt device="//< SERVER_HOSTNAME >/< DATA_DIR >"
    --opt o="addr=< SERVER_HOSTNAME >,username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777"
    --name cif_volume
  2. docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test

< CONTAINER_ID >
docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/< VOLUME_NAME >/_data': failed to mount local volume: mount //< SERVER_ADDR >/< DATA_DIR >:/var/lib/docker/volumes/< VOLUME_NAME >/_data, data: addr=< SERVER_HOSTNAME >,username=< USERNAME >,password=*********,file_mode=0777,dir_mode=0777: invalid argument.

WORK AROUND

  1. docker volume create \
    --driver local
    --opt type=cifs
    --opt device="//< SERVER_ADDR >/< DATA_DIR >"
    --opt o="username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777"
    --name cif_volume
  2. docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test

< CONTAINER_ID >

Expected behavior

  • docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test should run without any error when following Docker documentation.
  • An execution of a shell inside the container should allow a user to access data in the docker volume, i.e.:
docker exec -ti test bash
ls /data
> Folder1   Folder2   ...

docker version

Client: Docker Engine - Community
 Version:           25.0.0
 API version:       1.44
 Go version:        go1.21.6
 Git commit:        e758fe5
 Built:             Thu Jan 18 17:09:49 2024
 OS/Arch:           linux/amd64
 Context:           default

docker info

Client: Docker Engine - Community
 Version:    25.0.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.12.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.24.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Additional Info

No response

@vvoland
Copy link
Collaborator

vvoland commented Jan 23, 2024

Starting from v25, Moby now performs the DNS resolution directly from the device opt.

Looks like the cifs treats passing both a resolved IP as device and addr or ip opt as an invalid argument error.

Try removing the addr option and specify the device using hostname directly:

docker volume create \
--driver local
--opt type=cifs
--opt device="//< SERVER_HOSTNAME >/< DATA_DIR >"
--opt o="username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777"
--name cif_volume

@Gwenn-LR
Copy link
Author

Thanks for your quick answer, I'll try this when my pipeline has finished !

@Gwenn-LR
Copy link
Author

Gwenn-LR commented Jan 23, 2024

I've tried your solution and I get an error but not the same.

I've tested multiple combination and I think I've managed to gather enought information to complete my answer.

To help you understand my exploration, here is some context:

  • I use gitlab/gitlab-runner:latest as an example image but any other image I've tried leads to the same behaviour.
  • my < DATA_DIR > has a space in its name (can't change it, I'm not the CIO of my organization).
  • I have to use quote around my password and they don't seem to work well with double quote after o= field.

EXPLORATION

docker volume create \
--driver local \
--opt type=cifs \
--opt device="//< SERVER_HOSTNAME >/< DATA_DIR_PREFIX >< SPACE_CARACTER >< DATA_DIR_SUFFIX >" \
--opt o=username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777 \
--name cif_volume

docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test

docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/cif_volume/_data': failed to mount local volume: mount //< SERVER_ADDR >/< DATA_DIR_PREFIX >%20< DATA_DIR_SUFFIX >:/var/lib/docker/volumes/cif_volume/_data, data: username=< USERNAME >,password=********,file_mode=0777,dir_mode=0777: no such file or directory.

docker volume create \
--driver local \
--opt type=cifs \
--opt device="//< SERVER_HOSTNAME >/< DATA_DIR_PREFIX >%20< DATA_DIR_SUFFIX >" \
--opt o=username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777 \
--name cif_volume

docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test

docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/cif_volume/_data': failed to mount local volume: mount //< SERVER_ADDR >/< DATA_DIR_PREFIX >%20< DATA_DIR_SUFFIX >:/var/lib/docker/volumes/cif_volume/_data, data: username=< USERNAME >,password=********,file_mode=0777,dir_mode=0777: no such file or directory.

docker volume create \
--driver local \
--opt type=cifs \
--opt device="//< SERVER_ADDR >/< DATA_DIR_PREFIX >%20< DATA_DIR_SUFFIX >" \
--opt o=username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777 \
--name cif_volume

docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test

docker: Error response from daemon: error while mounting volume '/var/lib/docker/volumes/cif_volume/_data': failed to mount local volume: mount //< SERVER_ADDR >/< DATA_DIR_PREFIX >%20< DATA_DIR_SUFFIX >:/var/lib/docker/volumes/cif_volume/_data, data: username=< USERNAME >,password=********,file_mode=0777,dir_mode=0777: no such file or directory.

docker volume create \
--driver local \
--opt type=cifs \
--opt device="//< SERVER_ADDR >/< DATA_DIR_PREFIX >< SPACE_CARACTER >< DATA_DIR_SUFFIX >" \
--opt o=username=< USERNAME >,password=< PASSWORD >,file_mode=0777,dir_mode=0777 \
--name cif_volume

docker run -d -v cif_volume:/data gitlab/gitlab-runner:latest --name test

OK

CONCLUSION

It seems that when the DNS resolution is performed, it converts the subdirectory special caracter (here the < SPACE_CARACTER > becomes a %20) hence the no such file or directory error. However, it's not the original subject of the issue and I can't change my environment to further test if your answer solves my first issue. If that's the case, an update of Docker documentation would be welcome.

In any case, thanks for the time you've already given to answer my issue.

@thaJeztah
Copy link
Member

This should be fixed by moby/moby#47191, which will be in the v25.0.1 release.

@Gwenn-LR
Copy link
Author

Thanks to all of the team for your reactivity ! Have a nice day !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants