It may seem obvious, but when you are dealing with permissions and ports, sometimes you forget the simplest things.
Ports lower than 1024 are "priviledged" ports and by convention only root accounts are allowed to open them. In our case example,
apache will open port 80 and potentially port 443 (https). To accomplish the goal or running the container as a standard user, you must configure
apache to run on another port and when running your container based on your image, you can bind the expected port to your configured internal port.
Note, if you attempt to execute the container to the default port, the container will not start.
For example, I recommend changing the configuration of apache to listen on a different port
#Inside the apache httpd.conf file
Listen 8080
# You can also apply this change in a virtual host entry
# You may also specify a port for https
#
Listen 8443
Finally, in your container build instruction, ie: docker-compose.yml file, you can expose the expected port to the container's internal port.
version: '3'
services:
app:
image: httpd:custom
ports:
- "80:8080"
- "443:8443"
volumes:
- /path/to/your/updated.conf:/usr/local/apache2/conf/httpd.conf
- /path/to/your/ssl-updated.conf:/usr/local/apache2/conf/extra/httpd-ssl.conf
After completing these overall steps, you will have a container that is executed with a regular account, not as root.