Fun with Containerized WordPress and App Services

I ran across an issue where WordPress was not installing properly for a customer when they utilized the default WordPress:php8.3-apache as their base image with some additional configurations. I generally do not work a lot of with docker or PHP but took the my existing knowledge to the work.

There are some differences in how Entrypoints and CMD is used within a Docker file. Ask your friendly CoPilot or ChatGPT for the response but here’s an excerpt of what I received when I asked. As always with any response from AI, do your own research to confirm…


After some investigation in trying to understand the behavior, I realized the default image doesn’t actually install WordPress into the right directory if you make changes to the entrypoint command in a shell (.sh) script. Running the docker image locally returned the 403 response from Apache indicating there’s nothing it can actually serve up, similar to IIS reporting a 403 for no default document found.

If I run this simplified docker file below locally just running the WordPress image with a CMD entry instead of modifying a .sh shell script to start Apache you’ll notice the output from the logs indicate something is installing WordPress. There is a wp folder but its not actually an install of WordPress.

# Stage 2: Setup WordPress
FROM wordpress:php8.3-apache

# Expose port 443
EXPOSE 443
EXPOSE 80

CMD ["apache2-foreground"]

Adding the line below will install WordPress, similar to what the mechanism in the default image is doing. 

# Set up WordPress
WORKDIR /var/www/html
RUN curl -o wordpress.tar.gz https://wordpress.org/latest.tar.gz; \
   tar -xzf wordpress.tar.gz --strip-components=1; \
   rm wordpress.tar.gz

Here’s my working example – I added SSH support, because who doesn’t love full access to the container via Kudu. 
https://azureossd.github.io/2022/04/27/2022-Enabling-SSH-on-Linux-Web-App-for-Containers/index.html

# Stage 2: Setup WordPress
FROM wordpress:php8.3-apache

COPY entrypoint.sh ./

# Start and enable SSH
RUN apt-get update \
   && apt-get install -y --no-install-recommends dialog \
   && apt-get install -y --no-install-recommends openssh-server \
   && echo "root:Docker!" | chpasswd \
   && chmod u+x ./entrypoint.sh
COPY sshd_config /etc/ssh/

EXPOSE 8000 2222


# Expose port 443
EXPOSE 443
EXPOSE 80

# Set up WordPress
WORKDIR /var/www/html
RUN curl -o wordpress.tar.gz https://wordpress.org/latest.tar.gz; \
  tar -xzf wordpress.tar.gz --strip-components=1; \
  rm wordpress.tar.gz

# Set entrypoint

ENTRYPOINT [ "./entrypoint.sh" ]

entrypoint.sh

#!/bin/sh
set -e
service ssh start

exec apache2-foreground

Happy dockering…