Add new command to CMD without overriding existing


Add new command to CMD without overriding existing



I'm want to use existing docker image and add new command without overiding commands in cmd.



Dockerfile


FROM telegrammessenger/proxy

COPY mtproto_stats .

CMD [ "/bin/sh", "-c", "/bin/bash /run.sh", "/bin/bash ./mtproto_stats" ]



Here i try to execute my programm which i copied to container CMD [ "/bin/sh", "-c", "/bin/bash /run.sh", "./mtproto_stats" ]



This commands "/bin/sh", "-c", "/bin/bash /run.sh" i got using docker inspect on running container


"/bin/sh", "-c", "/bin/bash /run.sh"


docker inspect



My programm should run with container and work all time, i'm trying use "./mtproto_stats & disown" but it not help


"./mtproto_stats & disown"





It's not clear what you are trying to achieve.
– dpwrussell
Jun 30 at 13:49





@dpwrussell run /run.sh an then ./mtproto_stats, but ./mtproto_stats run only if i put it to entrypoint, but if put it to entrypoint /run.sh will not run
– H.Denison
Jun 30 at 14:36



/run.sh


./mtproto_stats


./mtproto_stats


/run.sh





I don't think you understand what entrypoint and command actually do and also how command works. command is not a list of commands, it is a single command. If you want your container to do two things then you will need to make a run-script that you make the entrypoint. The run-script will then launch run.sh and then mtproto_stats, either one after the other, or if one/both are services, then by using one of many techniques to detach those processes.
– dpwrussell
Jun 30 at 18:13


entrypoint


command


command


run.sh


mtproto_stats




1 Answer
1



This commands "/bin/sh", "-c", "/bin/bash /run.sh" i got using docker inspect on running container


"/bin/sh", "-c", "/bin/bash /run.sh"



"/bin/sh", "-c" is the default ENTRYPOINT, "/bin/bash /run.sh" is the CMD.


"/bin/sh", "-c"


ENTRYPOINT


"/bin/bash /run.sh"


CMD



In your case, you should have, using the shell form of CMD:


FROM telegrammessenger/proxy

COPY mtproto_stats .
COPY wrapper.sh /wrapper.sh
CMD exec /wrapper.sh



With wrapper.sh:


#!/bin/bash
exec /path/to/mtproto_stats & disown
exec /run.sh



I place run.sh at the end, as it is supposed to be the main process, which keep the container alive.


run.sh






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to input without newline? (Python)

C++ thread error: no type named ‘type’ MINGW

Analog for TagView in flutter