I need to clone code while creating docker container not while building image. How can we achieve this or How can we run commands while creating container. I have used CMD git clone "URL"
in docker file but is giving error "Option 'c' is unknown. Ignoring" while running container.
Asked
Active
Viewed 896 times
1

San
- 69
- 1
- 8
-
Why do you want to do this? The command when you create the image is an endpoint and more recommend to run the application. – Charles Xu Apr 29 '20 at 07:53
-
@CharlesXu I explain in details. I need to have online IDE code assessment for students. So I have used code-server as online VS code editor. I need to have different projects to give to students so they will code it and check in the code. So I am trying to clone git project while container creation . – San Apr 29 '20 at 08:41
-
I am planning to create new branch for every students once they start assessment and they can check in code there. You can guide if you have any better solution on this. – San Apr 29 '20 at 08:43
-
@CharlesXu one more thing I tried ```RUN git clone --progress --verbose https://github.com/sanjayme97/dotnet-core-demo.git ``` in docker file but while building git code is not cloning it shows ``removing intermediate container``` and skipping the command. – San Apr 29 '20 at 08:49
-
It just removes the layer, I think it does not affect the image. See the [issue](https://stackoverflow.com/questions/48357742/how-to-clone-git-repo-using-dockerfile). – Charles Xu Apr 29 '20 at 09:48
-
ok fine tq. check this out please https://stackoverflow.com/questions/61501945/running-commands-in-azure-container-instance-after-container-running – San Apr 29 '20 at 12:39