我在WSL环境中使用docker-compose。我注意到由正在运行的Docker容器创建的一些文件显示为user=root和group=root。如何更改docker-compose以在当前UID和GID下创建新文件?
我发现在WSL bash shell中,我可以像普通用户一样删除属于root:root的文件,而无需sudo。相反,正在运行的Docker容器不能删除文件,即使该文件不是由root拥有。
这些文件位于/mnt/c/project-new/...,或在Windows中位于c:\project-new。
/etc/wsl.conf
在您提问之前,Linux权限的元数据定义在
我正在使用
运行命令
我的
我发现在WSL bash shell中,我可以像普通用户一样删除属于root:root的文件,而无需sudo。相反,正在运行的Docker容器不能删除文件,即使该文件不是由root拥有。
这些文件位于/mnt/c/project-new/...,或在Windows中位于c:\project-new。
/etc/wsl.conf
[network]
generateResolvConf = true
在您提问之前,Linux权限的元数据定义在
/etc/fstab
中:LABEL=cloudimg-rootfs / ext4 defaults 0 0
C: /mnt/c drvfs defaults,metadata 0 0
我正在使用
Win 10 20H2 (OS Buidl 19042.928) WSL Version 2
。运行命令
cat /etc/*release
。DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
我的
docker-compose.yml
文件如下:version: "3.2"
services:
ssc-file-generator-db2-test:
container_name: "ssc-file-generator-db2-test"
image: ibmcom/db2:latest
hostname: db2server
privileged: true
env_file: ["acceptance-run.environment"]
ports:
- 50100:50000
- 55100:55000
networks:
- back-tier
restart: "no"
volumes:
- setup-sql:/setup-sql
- db2-shell-scripts:/var/custom
- host-dirs:/host-dirs
- database:/database
networks:
back-tier:
external: true
volumes:
setup-sql:
driver: local
driver_opts:
o: bind
type: none
device: ./setup-sql
db2-shell-scripts:
driver: local
driver_opts:
o: bind
type: none
device: ./db2-shell-scripts
host-dirs:
driver: local
driver_opts:
o: bind
type: none
device: ./host-dirs
flyway_wait_bin:
driver: local
driver_opts:
o: bind
type: none
device: ./flyway/wait_bin
flyway_conf:
driver: local
driver_opts:
o: bind
type: none
device: ./flyway/conf
flyway_drivers:
driver: local
driver_opts:
o: bind
type: none
device: ./flyway/drivers
flyway_sql:
driver: local
driver_opts:
o: bind
type: none
device: ./flyway/sql
flyway_jars:
driver: local
driver_opts:
o: bind
type: none
device: ./flyway/jars
database:
driver: local
driver_opts:
o: bind
type: none
device: ./database
docker-compose
通常在哪里?我已经谷歌了一下,但我在/usr/local/bin
或~/.docker
中都找不到它。提前致谢! :) - GigiSan/usr/bin
找到了,抱歉 :) - GigiSan