Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker & Wordpress - The uploaded file could not be moved to wp-content/uploads/.../

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.

like image 752
Micheal J. Roberts Avatar asked Nov 29 '18 12:11

Micheal J. Roberts


People also ask

What's Docker used for?

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.

What is Docker vs Kubernetes?

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.

What is Docker in simple terms?

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.

What is Docker and do I need it?

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.


1 Answers

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.

  1. Set the correct user/group on the uploads folder: $ chown -R www-data:www-data uploads/*
  2. Set the correct permissions: $ chmod 755 uploads/*
like image 162
Sven van Zoelen Avatar answered Oct 09 '22 01:10

Sven van Zoelen