After trying to test Dockerfiles with Dockerspec, I finally had a problem. I cannot solve it correctly.
The problem is what I think from Docker himself; If I understand its process, the entry point is only executed at startup , but if the container remains on and I run the exec command, it will not be called again.
I think this is the desired behavior.
But if Entrypoint is a gosu "script that precedes all my commands, this is the problem ...
Example
"myImage" has this entry point: gosu 1000:1000 " $@ "
If I run: docker run -it myImage id -u
The output signal is "1000".
If I run the container: docker run -it myImage bash
In this container id -u displays "1000".
But if I run a new command in this container, it starts a new shell and would not execute Entrypoint, therefore: docker exec CONTAINER_ID id -u
Print "0" because the new shell starts as "root".
Is there a way to execute an input point each time? Or reuse the shell open?
Or is the best way to do this?
Or maybe I didnβt understand anything ?;)
Thanks!
EDIT
After reading the solutions suggested here, I understand that the problem is not how Docker works, but how Serverspec works; my goal is to directly test the command as a docker run argument, but Serverspec launches the container and tests the commands with docker exec .
So, the best solution is to find how to get the stdout docker run executed by Serverspec.
But, in my personal case, the best solution might be to not use Gosu, but the userβs flag :)