I want to create a nginx container that copies the content of my local machine /home/git/html into container /usr/share/nginx/html. However I cannot use Volumes and Mountpath, as my kubernetes cluster has 2 nodes. I decided instead to copy the content from my github account. I then created this dockerfile:
FROM nginx
CMD ["apt", "get", "update"]
CMD ["apt", "get", "install", "git"]
CMD ["git", "clone", "https://github.com/Sonlis/kubernetes/html"]
CMD ["rm", "-r", "/usr/share/nginx/html"]
CMD ["cp", "-r", "html", "/usr/share/nginx/html"]
The dockerfile builds correctly, however when I apply a deployment with this image, the container keeps restarting. I know that once a docker has done its job, it shutdowns, and then the deployment restarts it, creating the loop. However when applying a basic nginx image it works fine. What would be the solution ? I saw solutions running a process indefinitely to keep the container alive, but I do not think it is a suitable solution.
Thanks !