I have a dockerfile that starts from FROM ubuntu:20.04. It runs apt-get update and install nordvpn, python3.6, pip and Python dependencies. It copies my clientscript.py in the folder /usr/local/bin/ just like start.sh and finally, the dockerfiles ends with:
COPY ./start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh
# Use the start script as the entrypoint
ENTRYPOINT ["/usr/local/bin/start.sh"]
I can build my image without any problems from the terminal:
> docker build -t virtualclient .
From a serverscript.py, I run the container 20 times (one by one) with a different argument cl>
cl = 1 (this is number 1...20)
container = dockerclient.containers.run("virtualclient", cl, cap_add=['NET_ADMIN'], detach=True)
The docker container starts succesfully with entrypoint start.sh. The code for start.sh:
#!/bin/bash
echo "Start virtualclient$1"
/etc/init.d/nordvpn start && sleep 5
case "$1" in
"1") nordvpn login --token mytoken
nordvpn connect be
;;
"2") nordvpn login --token mytoken
nordvpn connect ie
;;
"3") nordvpn login --token mytoken
nordvpn connect de
;;
(But then 20 times for each client)
esac
python3 /usr/local/bin/Client_v3_virtual.py $1
echo "Start script with argument $1"
# Keep the container running
tail -f /dev/null
Via docker logs, I see that client starts with the right client number and makes connection with nordvpn. But the script Client_v3_virtual.py with argument $1 doesnât always start, or it starts but only after a long time. I also do not see the echo âStart script with argument $1â So itâs like the docker container hangs in starting the script.
Since that it sometimes works and sometimes not, I have no idea what do change in my start.sh.
I hope that my description is clear enough and somebody can help.
thanks in advance.