Docker multiple entrypoints

后端 未结 9 865
情深已故
情深已故 2020-12-13 00:08

Say I have the following Dockerfile:

FROM ubuntu

RUN apt-get update
RUN apt-get install -y apache2
RUN apt-get install -y mongod #pretend this exists

EXPOS         


        
9条回答
  •  温柔的废话
    2020-12-13 00:34

    I was not able to get the usage of && to work. I was able to solve this as described here: https://stackoverflow.com/a/19872810/2971199

    So in your case you could do:

    RUN echo "/usr/sbin/apache2" >> /etc/bash.bashrc
    RUN echo "/path/to/mongodb" >> /etc/bash.bashrc
    ENTRYPOINT ["/bin/bash"]
    

    You may need/want to edit your start commands.

    Be careful if you run your Dockerfile more than once, you probably don't want multiple copies of commands appended to your bash.bashrc file. You could use grep and an if statement to make your RUN command idempotent.

提交回复
热议问题