“already exists and is not an empty directory” for Empty Directory using Docker The 2019 Stack Overflow Developer Survey Results Are InHow can I add an empty directory to a Git repository?How to modify existing, unpushed commits?Make an existing Git branch track a remote branch?Ignore files that have already been committed to a Git repositoryMove existing, uncommitted work to a new branch in GitHow is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from host to Docker container

How to support a colleague who finds meetings extremely tiring?

How to display lines in a file like ls displays files in a directory?

Slides for 30 min~1 hr Skype tenure track application interview

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Why are there uneven bright areas in this photo of black hole?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?

What is the light source in the black hole images?

Are spiders unable to hurt humans, especially very small spiders?

What do I do when my TA workload is more than expected?

How to obtain a position of last non-zero element

Can a flute soloist sit?

The phrase "to the numbers born"?

How can I define good in a religion that claims no moral authority?

Kerning for subscripts of sigma?

How do PCB vias affect signal quality?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Is bread bad for ducks?

What is the meaning of Triage in Cybersec world?

How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?

Star Trek - X-shaped Item on Regula/Orbital Office Starbases

Is it okay to consider publishing in my first year of PhD?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?



“already exists and is not an empty directory” for Empty Directory using Docker



The 2019 Stack Overflow Developer Survey Results Are InHow can I add an empty directory to a Git repository?How to modify existing, unpushed commits?Make an existing Git branch track a remote branch?Ignore files that have already been committed to a Git repositoryMove existing, uncommitted work to a new branch in GitHow is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from host to Docker container



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I've been working on a Docker image that pulls necessary files from a github repo and then builds itself. It is intended to just update itself from github each time, but to test it I have been deleting the entire github repo folder each time it runs.



After deleting the folder, I started getting




fatal: destination path 'Project-4' already exists and is not an
empty directory.




The contents of the Dockerfile (the file that builds the image) are:



FROM python:3.7
WORKDIR /usr/src/app
CMD ["sh", "-c", "git clone https://github.com/nathanhtaylor/Project-4.git && cd ./Project-4 && pip install -r requirements.txt && python server.py"]


There is no directory Project-4 anywhere on this machine. This error happens no matter what folder the image runs out of. Running git clone http://github.com/nathanhtaylor/Project-4.git manually works fine.










share|improve this question






























    1















    I've been working on a Docker image that pulls necessary files from a github repo and then builds itself. It is intended to just update itself from github each time, but to test it I have been deleting the entire github repo folder each time it runs.



    After deleting the folder, I started getting




    fatal: destination path 'Project-4' already exists and is not an
    empty directory.




    The contents of the Dockerfile (the file that builds the image) are:



    FROM python:3.7
    WORKDIR /usr/src/app
    CMD ["sh", "-c", "git clone https://github.com/nathanhtaylor/Project-4.git && cd ./Project-4 && pip install -r requirements.txt && python server.py"]


    There is no directory Project-4 anywhere on this machine. This error happens no matter what folder the image runs out of. Running git clone http://github.com/nathanhtaylor/Project-4.git manually works fine.










    share|improve this question


























      1












      1








      1


      1






      I've been working on a Docker image that pulls necessary files from a github repo and then builds itself. It is intended to just update itself from github each time, but to test it I have been deleting the entire github repo folder each time it runs.



      After deleting the folder, I started getting




      fatal: destination path 'Project-4' already exists and is not an
      empty directory.




      The contents of the Dockerfile (the file that builds the image) are:



      FROM python:3.7
      WORKDIR /usr/src/app
      CMD ["sh", "-c", "git clone https://github.com/nathanhtaylor/Project-4.git && cd ./Project-4 && pip install -r requirements.txt && python server.py"]


      There is no directory Project-4 anywhere on this machine. This error happens no matter what folder the image runs out of. Running git clone http://github.com/nathanhtaylor/Project-4.git manually works fine.










      share|improve this question
















      I've been working on a Docker image that pulls necessary files from a github repo and then builds itself. It is intended to just update itself from github each time, but to test it I have been deleting the entire github repo folder each time it runs.



      After deleting the folder, I started getting




      fatal: destination path 'Project-4' already exists and is not an
      empty directory.




      The contents of the Dockerfile (the file that builds the image) are:



      FROM python:3.7
      WORKDIR /usr/src/app
      CMD ["sh", "-c", "git clone https://github.com/nathanhtaylor/Project-4.git && cd ./Project-4 && pip install -r requirements.txt && python server.py"]


      There is no directory Project-4 anywhere on this machine. This error happens no matter what folder the image runs out of. Running git clone http://github.com/nathanhtaylor/Project-4.git manually works fine.







      git docker






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 4:44









      Suraj Kumar

      2,79841026




      2,79841026










      asked Mar 22 at 4:32









      Nathan TaylorNathan Taylor

      82




      82






















          1 Answer
          1






          active

          oldest

          votes


















          0














          There is a flaw in the way you are building your Docker image. Docker images are supposed to be immutable i.e once you build them you should be only able to run it using the built executable and not change it. Docker images are and can be versioned just like your source codes.



          In your example you are trying to do the process of build , getting the dependencies and execution all in CMD which is against the principles of how and why containers must be used and the problem they try to solve.



          I suggest reading this article to understand why Immutability is required



          https://medium.com/sroze/why-i-think-we-should-all-use-immutable-docker-images-9f4fdcb5212f



          As to your Dockerfile i would suggest you change it to get the git repository and requirements as part of docker build steps and out of CMD and only keep the executable there.



          In the scenario you stated, ideally your CI(continuous integration) or any other pipeline should have a phase to rebuild Docker image from scratch if your remote git repository has any changes and version it accordingly and mark it latest tag.



          Also , this link has a nice way to building docker images using remote git repositories which might be useful in your scenario if you dont want to use a CI pipeline of sorts.






          share|improve this answer

























          • All true, but does this explain the observed error?

            – OhleC
            Mar 22 at 9:09











          • Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

            – fatcook
            Mar 22 at 9:19











          • So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

            – OhleC
            Mar 22 at 9:24











          • You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

            – fatcook
            Mar 22 at 10:20











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292964%2falready-exists-and-is-not-an-empty-directory-for-empty-directory-using-docker%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          There is a flaw in the way you are building your Docker image. Docker images are supposed to be immutable i.e once you build them you should be only able to run it using the built executable and not change it. Docker images are and can be versioned just like your source codes.



          In your example you are trying to do the process of build , getting the dependencies and execution all in CMD which is against the principles of how and why containers must be used and the problem they try to solve.



          I suggest reading this article to understand why Immutability is required



          https://medium.com/sroze/why-i-think-we-should-all-use-immutable-docker-images-9f4fdcb5212f



          As to your Dockerfile i would suggest you change it to get the git repository and requirements as part of docker build steps and out of CMD and only keep the executable there.



          In the scenario you stated, ideally your CI(continuous integration) or any other pipeline should have a phase to rebuild Docker image from scratch if your remote git repository has any changes and version it accordingly and mark it latest tag.



          Also , this link has a nice way to building docker images using remote git repositories which might be useful in your scenario if you dont want to use a CI pipeline of sorts.






          share|improve this answer

























          • All true, but does this explain the observed error?

            – OhleC
            Mar 22 at 9:09











          • Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

            – fatcook
            Mar 22 at 9:19











          • So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

            – OhleC
            Mar 22 at 9:24











          • You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

            – fatcook
            Mar 22 at 10:20















          0














          There is a flaw in the way you are building your Docker image. Docker images are supposed to be immutable i.e once you build them you should be only able to run it using the built executable and not change it. Docker images are and can be versioned just like your source codes.



          In your example you are trying to do the process of build , getting the dependencies and execution all in CMD which is against the principles of how and why containers must be used and the problem they try to solve.



          I suggest reading this article to understand why Immutability is required



          https://medium.com/sroze/why-i-think-we-should-all-use-immutable-docker-images-9f4fdcb5212f



          As to your Dockerfile i would suggest you change it to get the git repository and requirements as part of docker build steps and out of CMD and only keep the executable there.



          In the scenario you stated, ideally your CI(continuous integration) or any other pipeline should have a phase to rebuild Docker image from scratch if your remote git repository has any changes and version it accordingly and mark it latest tag.



          Also , this link has a nice way to building docker images using remote git repositories which might be useful in your scenario if you dont want to use a CI pipeline of sorts.






          share|improve this answer

























          • All true, but does this explain the observed error?

            – OhleC
            Mar 22 at 9:09











          • Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

            – fatcook
            Mar 22 at 9:19











          • So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

            – OhleC
            Mar 22 at 9:24











          • You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

            – fatcook
            Mar 22 at 10:20













          0












          0








          0







          There is a flaw in the way you are building your Docker image. Docker images are supposed to be immutable i.e once you build them you should be only able to run it using the built executable and not change it. Docker images are and can be versioned just like your source codes.



          In your example you are trying to do the process of build , getting the dependencies and execution all in CMD which is against the principles of how and why containers must be used and the problem they try to solve.



          I suggest reading this article to understand why Immutability is required



          https://medium.com/sroze/why-i-think-we-should-all-use-immutable-docker-images-9f4fdcb5212f



          As to your Dockerfile i would suggest you change it to get the git repository and requirements as part of docker build steps and out of CMD and only keep the executable there.



          In the scenario you stated, ideally your CI(continuous integration) or any other pipeline should have a phase to rebuild Docker image from scratch if your remote git repository has any changes and version it accordingly and mark it latest tag.



          Also , this link has a nice way to building docker images using remote git repositories which might be useful in your scenario if you dont want to use a CI pipeline of sorts.






          share|improve this answer















          There is a flaw in the way you are building your Docker image. Docker images are supposed to be immutable i.e once you build them you should be only able to run it using the built executable and not change it. Docker images are and can be versioned just like your source codes.



          In your example you are trying to do the process of build , getting the dependencies and execution all in CMD which is against the principles of how and why containers must be used and the problem they try to solve.



          I suggest reading this article to understand why Immutability is required



          https://medium.com/sroze/why-i-think-we-should-all-use-immutable-docker-images-9f4fdcb5212f



          As to your Dockerfile i would suggest you change it to get the git repository and requirements as part of docker build steps and out of CMD and only keep the executable there.



          In the scenario you stated, ideally your CI(continuous integration) or any other pipeline should have a phase to rebuild Docker image from scratch if your remote git repository has any changes and version it accordingly and mark it latest tag.



          Also , this link has a nice way to building docker images using remote git repositories which might be useful in your scenario if you dont want to use a CI pipeline of sorts.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 22 at 8:52

























          answered Mar 22 at 8:46









          fatcookfatcook

          45919




          45919












          • All true, but does this explain the observed error?

            – OhleC
            Mar 22 at 9:09











          • Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

            – fatcook
            Mar 22 at 9:19











          • So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

            – OhleC
            Mar 22 at 9:24











          • You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

            – fatcook
            Mar 22 at 10:20

















          • All true, but does this explain the observed error?

            – OhleC
            Mar 22 at 9:09











          • Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

            – fatcook
            Mar 22 at 9:19











          • So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

            – OhleC
            Mar 22 at 9:24











          • You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

            – fatcook
            Mar 22 at 10:20
















          All true, but does this explain the observed error?

          – OhleC
          Mar 22 at 9:09





          All true, but does this explain the observed error?

          – OhleC
          Mar 22 at 9:09













          Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

          – fatcook
          Mar 22 at 9:19





          Yes, because you are assuming that this is your machine you are running these commands on , whereas infact you are running them on the already built image.

          – fatcook
          Mar 22 at 9:19













          So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

          – OhleC
          Mar 22 at 9:24





          So? (I also noticed the asker seemed to assume this, but still don't see why git clone should show this error)

          – OhleC
          Mar 22 at 9:24













          You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

          – fatcook
          Mar 22 at 10:20





          You might want to delete your previous images and try one more time using docker rmi and see if that makes a difference. Also , use the --no-cache option of docker to ensure it is not using any intermediate images.

          – fatcook
          Mar 22 at 10:20



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55292964%2falready-exists-and-is-not-an-empty-directory-for-empty-directory-using-docker%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해