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

[windows] The process cannot access the file because it is being used by another process #330

Open
andyzhangx opened this issue Aug 10, 2020 · 10 comments

Comments

@andyzhangx
Copy link

andyzhangx commented Aug 10, 2020

I tried to use following config args: ["-u", "$(USERNAME);$(PASSWORD)", "-s", "share;/smbshare/;yes;no;no;all;none", "-p"] to set up a SMB server, and then mount one SMB share on multiple windows nodes, the first always succeeded, while the second mount always failed with The process cannot access the file because it is being used by another process, this issue only happens on Windows, is there any config wrong? Thanks.

Microsoft Windows [Version 10.0.17763.1339]
(c) 2018 Microsoft Corporation. All rights reserved.

azureuser@3460k8s001 C:\Users\azureuser>powershell
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\azureuser> Get-SmbGlobalMapping

Status Local Path Remote Path
------ ---------- -----------
OK                \\52.177.137.222\share

PS C:\Users\azureuser> exit

azureuser@3460k8s001 C:\Users\azureuser>mkdir /D abc \\52.177.137.222\share
The syntax of the command is incorrect.

azureuser@3460k8s001 C:\Users\azureuser>mklink /D abc \\52.177.137.222\share
symbolic link created for abc <<===>> \\52.177.137.222\share

azureuser@3460k8s001 C:\Users\azureuser>cd abc
The process cannot access the file because it is being used by another process.
@TheGiolly
Copy link

TheGiolly commented Aug 14, 2020

I'm having the same issue and also the error "Handle is invalid" in Windows.
From what I've read it's a problem in Samba 4.12.2 and it has been fixed in the next version.
It would be great if @dperson could update.


Just checked and the latest version of Samba available in the Alpine 3.12 branch is 4.12.2r1, so this docker container cannot be updated.
A workaround is switching to the edge branch and updating Samba to 4.12.5r0 (and all the system) doing the following:
sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories
apk update
apk upgrade

@andyzhangx
Copy link
Author

I'm having the same issue and also the error "Handle is invalid" in Windows.
From what I've read it's a problem in Samba 4.12.2 and it has been fixed in the next version.
It would be great if @dperson could update.

Just checked and the latest version of Samba available in the Alpine 3.12 branch is 4.12.2r1, so this docker container cannot be updated.
A workaround is switching to the edge branch and updating Samba to 4.12.5r0 (and all the system) doing the following:
sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories
apk update
apk upgrade

@TheGiolly thanks a lot! I could confirm that the fix(andyzhangx@26c899d) could really fix the permission issue on Windows. Still looking forward @dperson to make a fix in master branch.

Here is my fixed image: andyzhangx/samba:win-fix
My command to build docker image:

docker build --no-cache -t andyzhangx/samba:win-fix -f ./Dockerfile .

@TheGiolly
Copy link

The Samba package has been updated to 4.12.6-r0 on both the 3.12 and edge branches of Alpine.
So there is no more need to switch to edge, just update the packages with apk -U upgrade

@JamoDevNich
Copy link

For anyone else running into this issue, if you won't be deleting your samba container, here's a quick fix to run against it (credit to TheGiolly above)

docker exec -it samba /bin/bash -c "apk -U upgrade && pkill smbd"

The container will stop automatically (smbd not running) and restart with the latest version of Samba.

To check the container's samba version, use docker exec -it samba /bin/bash -c "smbd --version"

@noamokman
Copy link

Hey, I'm also having the same issue as #350, and was directed here.
Looks like we just need to build a new latest version, correct?

@bjoluc
Copy link

bjoluc commented Apr 27, 2021

With Docker Compose, you can simply replace image: dperson/samba with build: https://github.com/dperson/samba.git in the service definition to build the most recent version on your own 👍

@mhbates
Copy link

mhbates commented May 11, 2021

With Docker Compose, you can simply replace image: dperson/samba with build: https://github.com/dperson/samba.git in the service definition to build the most recent version on your own 👍

Do you know how to do this with the run command?

@JamoDevNich
Copy link

With Docker Compose, you can simply replace image: dperson/samba with build: https://github.com/dperson/samba.git in the service definition to build the most recent version on your own 👍

Do you know how to do this with the run command?

You could try the build command? The command would probably be something like docker build https://github.com/dperson/samba.git

@jtagcat
Copy link

jtagcat commented Dec 28, 2021

I did a small fork: https://github.com/jtagcat/samba
(weekly auto-updates)

You are welcome to use the image ghcr.io/jtagcat/samba:amd64

(:aarch64 and :armhf also available)

@bejas
Copy link

bejas commented Oct 2, 2023

I managed to update the smb version setting read_only to false and the entrypoint in the compose file like this

version: "3.8"

services:
  samba:
    image: dperson/samba:latest
    entrypoint: bash -c "([[ $(smbclient --version) == 'Version 4.12.2' ]] && apk -U upgrade || echo 'No upgrade required') && /sbin/tini -- /usr/bin/samba.sh"
    read_only: false
    ...

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

No branches or pull requests

8 participants