'Invalid unicode characters in docker for shared network volume
I am writing a program in python using docker and wanted access to a network shared volume. my docker-compose.yml is:
version: '3.7'
services:
testpathdocker:
build:
context: .
dockerfile: Dockerfile
volumes:
- TechPlots:/opt/app/static
volumes:
TechPlots:
driver_opts:
type: "cifs"
o: "user=alg,password=123"
device: "//192.168.154.137/share/TechPlots"
the file names in the shared folder are in Persian.
When the container is running, instead of the actual file names, their names in the container appear as invalid characters like question marks such as ????.jpg. I simply list the directory by python using os.getdir(PATH_TO_SHARE). How can I fix this?
Solution 1:[1]
I copied those files on my local computer and shared them with docker using docker volume and worked fine.
So the source of the problem is the way cifs works. Apparently, you should use iocharset=utf8 in the options to read Unicode filenames correctly from the network. So I changed the volume section into:
volumes:
TechPlots:
driver_opts:
type: "cifs"
o: "iocharset=utf8,user=alg,password=123"
device: "//192.168.154.137/share/TechPlots"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | saeedghadiri |
