Reputation: 173
I am deploying a Docker image (Wordpress) on Elastic Beanstalk using a single container deployment.
My deployment zip file includes:
public
folder containing a complete wordpress buildDockerfile
.ebextensions/permissions.config
The standard Wordpress image creates a volume VOLUME /var/www/html
and in my Dockerfile I do
COPY ./public /var/www/html
Now the problem is that I cannot upload media using Wordpress admin dashboard.
Unable to create directory wp-content/uploads/2019/02. Is its parent directory writable by the server?
I've tried to change the permissions on the uploads folder using the EB config in .ebextensions/permissions.config
container_commands:
91writable_dirs:
command: |
chmod -R 777 /var/app/current/public/wp-content/uploads
cwd: "/var/app/current"
I see from the logs that the docker image gets built before running chmod
. I've seen on other SO posts that some run the script on /var/app/ondeck/
, but that fails with the directory doesn't exist
Despite all the above, my question is actually how do I get to upload media to Wordpress with my current setup.
EDIT: When I attach a shell to the docker container and change the file permissions of wp-content/uploads
in the VOLUME /var/www/html
I am able to upload media. So how can this be made permanent on the VOLUME?
Upvotes: 1
Views: 560
Reputation: 71
Whenever wordpress docker image is built and run, the docker ENTRYPOINT of the wordpress image is executed first. Hence your command to change the directory permissions is not getting executed.
This ENTRYPOINT is a bash script located in /usr/local/bin/docker-entrypoint.sh
If you want your command to be executed, you could add your command to this script and it will be called every time your container starts.
You could do it the following way -
Start your container and copy the contents of the existing
docker-entrypoint.sh
Create a new docker-entrypoint.sh
outside the container and edit
that script to add your chmod
command at appropriate location.
In your Dockerfile
add a line to copy this new entrypoint to the
location /usr/local/bin/docker-entrypoint.sh
Upvotes: 1