Wordpress can be installed but not updated, my docker configuration has some problems.
Since the cms is very used I ask you if you can help me to correct my configuration.
I saw that there is a special wordpress image but I don’t like it very much because I want to be able to access the CMS files using a volume.
This happened to me even without Docker when I used WordPress years ago. I did not remember the cause so I just searched for “wordpress asks ftp” and the fiest result was this:
So it looks like it is a permission issue. Make sure your files are readable.
You are actually using a bind mount, not a volume. That “volumes:” keywoard is just misleading. If you use a volume, the permissions are probably right, but in case of a bind mount, you need to set the proper permissions. Which means, if I remember well, you need to set the owner of the files to 33 which is the userid of www-data
Thank you so much for your help.
I had also found that code but it doesn’t seem like a professional solution.
I tried to edit the code like this but the wp-it folder contains all red dots with white x.
1.How do I correct this problem?
My solution is unprofessional.
I would like to have a folder capable of hosting all CMS (wordpress, magento, prestashop, etc …) like that of the main hosting providers.
2.Do you share with my opinion?
This solution is also not bad but still not beautiful.
I also discovered a very strange new thing. After I restart Linux Ubuntu the red dots disappear and I can edit the files but Wordpress asks for the FTP parameters. I’m very confused.
4.Can you explain this fact to me?
// A) Before reboot
drwxrwxr-x 3 fe fe 4096 set 4 19:05 data-php
drwxr-xr-x 5 www-data www-data 4096 set 4 19:05 data-wordpress
// B) After reboot
drwxrwxr-x 3 fe fe 4096 set 4 19:05 data-php
drwxr-xr-x 5 fe www-data 4096 set 4 19:05 data-wordpress
I don’t know what red dots you mean, but the picuture you shared does not show any dot, only X-es. It probably means you can’t read or write it, but it depends on the software that you use to browse the files.
The fact that applications in containers can use different users is one of the points of running containers. HTTPD, PHP, NGINX and similar services are intentionally forking their main processes running those on behalf of a non-root user which is not even related to Docker. It is just for security reasons. So even if you use a VPS and and install httpd, you need to set proper file permissions. Which usually means each file which you want to be readable and writable are owned by “www-data”. In case of web hosting, they can give you an FTP access so when you upload files, everything gets the right permisions
Because I used wordpress years ago and I just searched for a solution, so I can’t tell you if the FS_METHOD is right or not… I think you could get the best answer for that from the WordPress forum.
Regarding the permission settings, I am not sure, but I think WordPress has a page where you can see the PHP settings so you can check what user is running WordPress. If it is not www-data, then the owner of the files should be what WordPress can see.
The following code shows how to download the ‘wordpress’ image from https://hub.docker.com, access the container shell, view the permissions of the various CMS files but not how to edit the permissions using Docker Compose.
I would like to recreate a work environment like that of classic hosting providers and then freely install all the CMS I want such as Wordpress, Drupal, Magento, Prestashop, etc … In practice I would like a folder to upload CMS files and be able to install and configure it from the browser.
the first result is okay, but the second may be more user friendly with more eamples:
chown -R www-data:www-data .
Run it in the container or as root from your host. Note that if you change the owner, you will not be able to edit the files from the host, but you don’t need to in production. During development you can change the permissions intsead of the owner:
A thousand thanks.
I can do it like this from the host:
cd /home/gi/Dropbox/DOCKER/Docker-Php-MySQL
docker compose down --volumes
sudo chown -R www-data:www-data /home/gi/Dropbox/DOCKER/Docker-Php-MySQL/volumes/data-php/wp-it
docker compose up -d --build
The serious problem of the code is that when I want to change the wordpress folder on the server I have to change the permissions on the file and this is very inconvenient. Not good as a solution.
I rather use the initial solution (777 as permission + define (‘FS_METHOD’, ‘direct’); in the Wordpress config file).
cd /home/gi/Dropbox/DOCKER/Docker-Php-MySQL
docker compose down --volumes
sudo chmod -R 777 /home/gi/Dropbox/DOCKER/Docker-Php-MySQL/volumes/data-php/wp-it
docker compose up -d --build
Is it so risky to assign those permissions even in production?
The fact that you run the server in a container will not stop hackers to use a vulnerability of WordPress and change your files in a container to show something that you don’t really want to see on your site. Although changing the owner of all files are not really better since the owner probably has all the permissions. Maybe not execution, but the best solution would be to change the permissions or ownerrs of the files and that WordPress need to write. That is something that you should be able to find out by reading the documentation or asking on the WordPress forum. As I pointed it out before, it is not a Docker issue, but also important without using containers. The only difference here is that you waht to be able to change files on the host and still let WordPress to access those files.
On the other hand, the files that WordPRess needs to write, are probably the ones that you don’t want to write frequently. For example generated configuration files or uploaded photos. The source code should not be writable by WordPress, so now that you know the problem was the permission, you can find out what files WordPeess needs to write and change the permission of those files only.
I also have to note that using you should not update WordPress running in containers. You should create a new Docker image. Since I used WordPress long time ago, I don’t know how easy it is (it was not easy then), but that is the right approach in case of containers. If you don’t like that, you will have more problems with containers and you may want to use virtual machines instead.
everything works perfectly but I can’t access the contents of the CMS. For example, if I want to download a photo from Google Cloud that I entered a year ago, I can’t do it.
If I use this type of volume instead:
volumes:
- ./volumes/data-wordpress:/var/www/html
I can access the contents but the permissions are not persistent. I give an example. 1) I install wordpress in the following way;
2) Everything works perfectly and I can’t edit wordpress files; 3) Restart the OS hosting Docker; 4) After the restart the permissions have changed in fact I can access the php files of the volume and edit them directly from the host system. 5) If I launch this command everything starts working again:
As you can see the permissions are not persistent. Is this a Docker bug or a bug in the image created to use Wordpress?
If I go to this link: https://hub.docker.com/_/wordpress
I find a ton of images. I would not like that among these there was an image more suitable for my case. What do you think?
@rimelek you haven’t tried my setup on your computer. If you had tried it you would have noticed that it works. I understand why it doesn’t work on my PC. The problem is Dropbox. If I move the project out of Dropbox, the permissions remain unchanged after the machine is restarted. Obviously the problem of permissions remains. I can read but not write. If I want to perform a wordpress restore on a real server I can’t do it. In the Docker documentation I read that there is a specific command to do this called “:rw”. I have tried this but it doesn’t solve.
All files are protected. I cannot edit the files contained in this folder. I thought that by writing “:rw” I would be able to edit all these files but this is not the case. I would like to make the files contained in “/volumes / data-wordpress” editable. The volume that Docker creates is not accessible.
Did you understand my question or not?
One solution I found is to use ‘user: my-user-id’ but that’s crap because Docker’s beauty fades in a flash. Could you recommend me a more professional solution?
What should I write to have a real volume?
I need to be able to backup and restore the container files. Some information I recover from the database but the photos do not.
The professional way is not accessing the files from the host written by the user in the container. During development, if you want to do that, you need to set the ownership, groups and permissions. The exact way to do that depends on the application. You can change the user that runs the process in the container, change the server settings to change the user that creates the files, change the file permissions so the group can write the files (currently it can’t), so you can add yourself to the group on the host and write the files. Otherwise you can write it with the root user.
That controlls the container not your host.
That is not a volume. That is just a bind mounted folder. Don’t let yourself to be confused by the “volumes” parameter.
What should I write to have a real volume?
I need to be able to backup and restore the container files. Some information I recover from the database but the photos do not.
Sorry, I can’t give you a command that you copy and paste and works. I mentioned you need to set proper permissions. You use WordPress, I don’t. I can help you with questions regarding Docker, but this is not about Docker anymore, but Linux basics and even though I would like to help everyone here, there is a point where draw the line and say you need to learn the basics in order to continue and I can’t learn it for you.
I also told you that editing files created by processes inside Docker containers is not “professional”. It is an understandable need sometimes during development, but then you need to figure out what your application requires and configure the permissions properly, That is different for every application so I can’t and I don’t want to give you a command that configures it some way and then something does not work for you because a folder is writable but it should not be writable and the application can’t start until you fix it, or I make a folder read-only and that is why the aplication cannot start. Of course the application in this case is WordPress and as I suggested for your previous question in this topic:
Sometimes when I have time and I like the topic because that topic helps me too some ways, I also do some research and find out how a software works, but this is not that case.
What I plan to do is create some videos or blog posts about some topics that can help everyone, like using an app with Docker during development, but WordPress is not something I plan to explain in the near future.
We also discussed multiple questions here and this is not the first topic in which we did that, but in this case I didn’t want to mention it until now. Please, try to focus on one problem and when you get some advice, try to learn, because using Linux containers also requires basic Linux skills. Without that, you will not be able to go far.
You have probably noticed that recently I am the only one who tries to reply to your questions and I also delay those replies because there are many questions asked by many users here but there are not many who can or want to answer and your questions require more time to answer because your goals are too big for your current knowledge. That’s why we need your help to do your research so you can learn much more and eventually even help someone else.
In the end some staticstics to show you how much time I have spent on your questions which you thanked me with your many likes which I appreciate of course.
You are the third person who liked my posts the most and the first and the second users were moderators in every topic where I helped someone.
You are the second person I replied to the most, and the first person is @meyay who also tried to help you and many other users and we replied to each others post a lot in many topics where we helped together.
I have also opened a discussion on the Italian site of WordPress and Linux but they don’t know how to help me.
Can the following code be broken into two lines?
CURRENT_UID=$(id -u):$(id -g) docker compose up -d --build
I would like to have the following code on one line:
docker compose up -d --build
P.S.: Which CMS do you use? Drupal? Joomla? Prestahop? Magento?