I am having difficulties surrounding the startup script i’m trying to use to setup my system. Specifically this happens when i’m trying to call my start script from the end of my dockerfile, and run things in the background.
Below are the end of my dockerfile and start script.
Dockerfile
…
COPY ./src/start.sh ./src/start.sh
# start will run when container starts up on the device
EXPOSE 80
ENV INITSYSTEM on
WORKDIR /usr/src
CMD sh start.sh
Start Script
#!/bin/bash -x
echo "Starting Machine Comms"
python3 /usr/src/machineComm/main.py &
echo "Starting the frontend"
npm start --prefix frontEnd/ &
echo “Complete”
I am certain that I am calling the start script, the “echo” calls always work.
I have tried the following test cases:
- Removing the & from line 3 of the start script. This results in the python getting called successfully but execution of the script stops.
- Changing “sh start.sh” to “bash start.sh” or just “start.sh” results in no significant change in behavior.
- SSHing in and running “bash start.sh” from the command line. The script will run, echo calls will work, python and node will start running (I can see the logs and process)
Based of of test (3) I believe that my docker file is setup correctly and that there is nothing wrong with the setup of my container. I just can not wrap my head around why there is a significant difference between the CMD at the end of my dockerfile and SSHing in and running it directly.
Any guidance hints or tips would be appreciated.
Thanks,
Sam