Search notes:

Dockerfile: Shell vs exec form

CMD

One of the differences between using the shell form and using the exec form in a Dockerfile's CMD instruction is the expansion or non-expansion of environment variables.

Shell form

A Dockerfile with a CMD instruction using the shell form:
FROM busybox

ENV txt="Hello world"
ENV num=42

CMD echo -e "txt=$txt\nnum=$num"
docker build -q -t cmd-shell-form .
docker run --rm    cmd-shell-form 
docker rmi         cmd-shell-form
With the shell form, the docker run command prints
txt=Hello world
num=42

Exec form

A Dockerfile with a CMD instruction using the exec form:
FROM busybox

ENV txt="Hello world"
ENV num=42

CMD ["echo", "-e", "txt=$txt\nnum=$num"]
docker build -q -t cmd-exec-form .
docker run --rm    cmd-exec-form 
docker rmi         cmd-exec-form
With the exec form, the docker run command prints
txt=$txt
num=$num

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759398026, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/tools/Docker/Dockerfile/instructions/vs/exec-vs-shell-form(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78