简体   繁体   English

如何编辑由 Laradock 工作区创建的文件

[英]How to edit files which are made by Laradock workspace

I've newly started to use Laradock to build my Laravel projects but I have a problem in editing the files such as Controllers, Models, etc which are made by the php artisan command in the Laradock workspace.我刚开始使用Laradock来构建我的 Laravel 项目,但是我在编辑由 Laradock 工作区中的php artisan命令创建的文件(例如控制器、模型等)时遇到问题。 The reason is the user in the workspace is a root and on the other side, I'm trying to edit the file in my editor by a common user.原因是工作区中的用户是根用户,而另一方面,我正在尝试由普通用户在我的编辑器中编辑文件。 So every time I have to run the command chmod -R 777 /newCreatedFile.php to change the permission.所以每次我必须运行命令chmod -R 777 /newCreatedFile.php来更改权限。 So is there any solution to handle this problem?那么有没有办法解决这个问题呢?

By the way my OS is ubuntu 18.04顺便说一下,我的操作系统是 ubuntu 18.04

In the Laradock Getting Started guide , it explains how to get Laradock running as a specified user:Laradock 入门指南 中,它解释了如何让 Laradock 以指定用户身份运行:

Note: You can add --user=laradock to have files created as your host's user.注意:您可以添加 --user=laradock 以将文件创建为主机用户。 Example:例子:

 docker-compose exec --user=laradock workspace bash

I believe this should solve your issue, as you will no longer have the Docker user running these commands.我相信这应该可以解决您的问题,因为您将不再让 Docker 用户运行这些命令。 Try it out!试试看!

Note: The core issue may just be that whatever user Laradock is running as is not creating files with group permissions that allows the host machine's user write capabilities, hence why the --user flag can be used.注意:核心问题可能只是 Laradock 运行的任何用户都没有创建具有允许主机用户写入功能的组权限的文件,因此为什么可以使用--user标志。 It may not actually be running as the root user itself.它实际上可能不是作为root用户本身运行的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM