I'm using dockerfile to create an Image And I want every time when the docker container starts the ssh connection should also start and then the ngrok should also start but I'm not able to use CMD command can you guys please help me with it.
FROM ubuntu
ENTRYPOINT echo "Entering......"; bin/bash; ngrok tcp 22
RUN apt-get update
RUN apt-get install curl -y
RUN apt-get install openssh-server -y
RUN curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | tee /etc/apt/sources.list.d/ngrok.list && apt update && apt-get install ngrok
RUN ngrok authtoken 25dYasdvM3C1IkDtT9QEG7ZwIWw_59Ar5Hp4NcrusbyVAu6Sv
CMD echo "SSH starting"
CMD service ssh start
CMD echo "SSH started"
CMD echo "started creating log file"
CMD echo "file created!!"
CMD ngrok tcp 22 --log=stdout > ngrok.log &
CMD echo "log file created"
CMD touch hello.txt
CMD echo "simple file created"
CMD echo "log file created and esatablished network successully"
CMD echo "working fine"
CMD echo "Starting!!!!"
To use multiple startup commands you need to either join them together using & or create an executable, something like this: Dockerfile:
...
CMD /start.sh
start.sh:
#!/bin/bash
service ssh start
ngrok tcp 22 --log=stdout > ngrok.log
....
Make sure the last command does not exit or the container will shutdown too. There are issues with running multiple commands like you cannot get logs using "docker logs" from the commands you ran, only the last executable etc.