Error:
The uploaded file could not be moved to wp-content/uploads/.../...
.
Environment:
Wordpress Docker image is created from a base Wordpress image then the files are mapped in and out, for development:
version: '3'
services:
wordpress:
restart: always
environment:
WORDPRESS_DB_NAME: ...
WORDPRESS_DB_HOST: ...
WORDPRESS_DB_USER: ...
WORDPRESS_DB_PASSWORD: ...
image: wordpress:latest
ports:
- 38991:80
volumes:
- ./:/var/www/html
We talk to a dev database hosted external to the Docker container.
Image is built - and sent up to the server. Then, CMS user attempts to upload an image and the Wordpress build moans that the uploaded file could not be moved to wp-content/uploads/.../...
. We don't get this error on localhost
.
Could some devops experts kindly point us in the right direction on what needs to be done for this to tally up on the server.
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.
Docker is a company which provides a set of tools for building and sharing container images, and running containers at both small and large scale. Kubernetes is a tool which manages (“orchestrates”) container-based applications running on a cluster of servers.
In simple terms, Docker is a software platform that simplifies the process of building, running, managing and distributing applications. It does this by virtualizing the operating system of the computer on which it is installed and running. The first edition of Docker was released in 2013.
There are many good things about Docker. It packs, ships, and runs applications as a lightweight, portable, and self-sufficient containerization tool. Docker is great for businesses of all sizes. When you are working on a piece of code in a small team, it eliminates the “but it works on my machine” problem.
The permissions are incorrect on the wp-content/uploads
directory. I had the same error and in my case the upload folder's permissions and user/group where set wrong and also some folders inside were set to root. But that's probably because I imported a backup.
To fix the upload you can add the following two commands to your deploy pipeline/script or use docker exec -it <container-name> bash
to perform it manually on the container.
$ chown -R www-data:www-data uploads/*
$ chmod 755 uploads/*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With