Just a quick example of how to run a script before actually starting a container's process.

This example will show a simple nginx container running some static html.

Dockerfile:

FROM nginx

# Copy the app files to the nginx root directory
COPY . /usr/share/nginx/html

# Copy the custom script
COPY run.sh /run.sh

# Run the custom script
CMD ["sh", "run.sh"]  

run.sh:

#!/bin/bash

# Set the api url based on an environment variable
sed -i "s|API_URL|${API_URL}|" /usr/share/nginx/html/app/app.config.js

nginx -g "daemon off;"  

Build the container and you're good to go!

docker build -t myname/myapp  
docker run -e API_URL=https://api.com myname/myapp