by Devin Yang
(This article was automatically translated.)

Published - 6 years ago ( Updated - 6 years ago )

foreword

The CCC website has been upgraded to php 7.2.0. With a Docker environment, it is easy to upgrade php.
There are still some precautions you should know about the change of Image on Linux.
If you install D-Laravel on a Linux system through docker like me, when you change a different image,
Perhaps you may encounter, doubt! Why composer does not have permission to write to the folder error.
directory is not writable

illustrate

In the Linux environment, the user of D-Laravel's built-in image is not root, and the default uid and gid are 1000.
It is very likely that it is different from the user uid and gid executed on your Linux, you can enter the id to check.
If the user uid and gid on your Linux are exactly 1000, basically there will be no problem in executing D-Laravel.
id command
But when your situation is the same as mine, uid and gid are not 1000, which will cause your users on Linux to execute composer,
If you do not have permission to write to the home directory of dlaravel, when you enter composer update,
You will see the following error: OK, this is normal, don't be too alarmed.

directory is not writable
The correction method is very simple. To put it bluntly, just change the uid and gid of dlaravel to be the same as the uid and gid of the Linux user you are running.

If you are not familiar with Linux instructions or Docker, or if you are quite familiar with Linux instructions, it is just a lazy adjustment.
The goal of D-Laravel development is to let people who don't understand Docker or who understand Docker can use the simplest way to get the environment,
Of course, D-Laravel has provided converted bash.

D-Laravel's correction method:

We can use the ./console chowner method provided by D-Laravel to easily adjust.
How to identify ./console chowner ? Here I adopted a very rough and direct method, which is to directly cut off the dlaravel users in the container.
Then execute the user id and gid of ./console chowner ,
Create the same dlaravel user in the container, and then change the permissions of the dlaravel home directory.

Crude enough, but it works.
./console chowner
The latest version of D-Laravel no longer uses this brutal method to change the user's uid and gid, and there is a better way.
https://www.ccc.tc/article/dlaravel-release-v1.5.5

When we rebuilt the dlaravel user in the container through ./console chowner ,
We need to write the changes and write data to the image of deivny/fpm used ,
Due to the docker-compose environment, the container will be removed when down is executed.
So we have to save the container changes into the image template,
In this way, the execution container will be the environment we changed when the next startup occurs.

In this example, I am using version 7.2.0 of php, so find out the CONTAINER ID of fpm.
docker ps

Then commit and restart.
commit
After completion, enter the container, and then run to see composer update .

You can see that after changing the permission, it can be updated normally, and composer will no longer complain about not having permission to write to the added directory.
composer update

If you have any questions about the use of D-Laravel, please leave a message in the chat room.

Tags: docker

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


docker

How to simply use Docker to create an internet command line speed test program?

How to simply use Docker to create an internet command line speed test program? Here we use the python program speedtest-cli Will use Docker for the main use case, for example, I want to test the speed in my NAS, Although there is python in my NAS, but there is no pip command, it feels much safer to use Docker at this time. Of course, your NAS needs to be able to run Docker :). Or, I am in a MacOS environment, and I don't want to install speedtest-cli into my MacOS. At this time, it is not bad to use Docker to build a simple execution environment by yourself.

certbot,docker,ftp

curlftpfs introduction and manual certificate application

Situation sharing, imagine that you have WebHosting, which only provides FTP connection, and then you want to apply for a certificate manually. In this article, I share how I use Docker to install curlftpfs, mount the FTP folder of the remote host, and then execute certbot in the container to apply for an SSL certificate. Leaving aside the certificate application, when I first discovered the curlftpfs command, I found it very interesting, especially if you are a MacOS user and do not have a satisfactory FTP software at hand. You love scrolling through the command line as much as I do, so maybe you should love this command too. 🤭

dlaravel,docker

D-Laravel learning three stages

Chat about the three stages of using D-Laravel, why use D-Laravel. Because the configuration files used by D-Laravel are quite simple, it is very suitable for beginners of Docker to learn, And users who do not know how to use Docker can also use the two commands ./console and ./create to create a project.