I have a Dockerfile that installs multiple services on a ubuntu baseimage such as npm, nodejs and ssh.
I want be able to ssh into the container and also run a node express application.
It works perfectly to run one of that. But i cant figure out how to start both services!
To run ssh i did:
CMD ["/usr/sbin/sshd","-D"]
For the node application i clone a git repo and run:
CMD ["node" "app.js"]
Each of that runs perfectly.
But how can i execute both commands?
I tried putting them both in the CMD directive:
CMD ["/usr/sbin/sshd","-D", "node", "app.js"]
I also tried to execute one of them with RUN:
RUN node app.js
CMD ["/usr/sbin/sshd","-D"]
It executes but is than stuck at this point and doesnt continue to compute the image..
How can i execute /usr/sbin/sshd -D (which i need to run ssh) and also node app.js?
Heres the full Dockerfile:
FROM ubuntu:latest
RUN apt update && apt install openssh-server sudo -y
RUN apt install git -y
RUN apt install nodejs -y
RUN apt install npm -y
RUN npm install express
RUN npm install better-sqlite3
RUN npm install morgan
RUN echo "PermitRootLogin yes">etc/ssh/sshd_config
RUN echo 'root:root' | chpasswd
RUN git clone https://github.com/mauriceKalevra/Web2-Projekt.git
WORKDIR Web2-Projekt
RUN npm install
RUN service ssh start
EXPOSE 22
#CMD ["/usr/sbin/sshd","-D", "&&", "node", "app.js"lss" ]
CMD ["node", "app.js"]