How to execute the Entrypoint of a Docker images at each “exec” command?

后端 未结 1 1740
不知归路
不知归路 2021-02-13 13:42

After trying to test Dockerfiles with Dockerspec, I finally had an issue I can\'t resolve properly.

The problem is, I think, from Docker itself ; If I understand its pro

1条回答
  •  被撕碎了的回忆
    2021-02-13 14:11

    if your goal is to run the docker exec with a specific user inside of the container, you can use the --user option.

    docker exec --user myuser container-name [... your command here]

    If you want to run gosu every time, you can specify that as the command with docker exec

    docke exec container-name gosu 1000:1000 [your actual command here]

    in my experience, the best way to encapsulate this into something easily re-usable is with a .sh script (or .cmd file in windows).

    drop this into a file in your local folder... maybe gs for example.

    #! /bin/sh
    docker exec container-name gosu 1000:1000 "$@"

    give it execute permissions with chmod +x gs and then run it with ./gs from the local folder

    0 讨论(0)
提交回复
热议问题