docker compose volume type - bind vs volumeHow is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersHow to deal with persistent storage (e.g. databases) in DockerCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryDocker-compose overwriting package.json

Should students have access to past exams or an exam bank?

Antonym of "Megalomania"

What are these bugs on my milkweed?

What are the closest international airports in different countries?

How to innovate in OR

What Marvel character has this 'W' symbol?

Why are subdominants unstable?

Correct word for a little toy that always stands up?

How do I make my photos have more impact?

Can machine learning learn a function like finding maximum from a list?

What clothes would flying-people wear?

Patio gate not at right angle to the house

Prepare a user to perform an action before proceeding to the next step

Scam? Checks via Email

Can living where Earth magnet ore is abundent provide any protection?

Security measures that could plausibly last 150+ years?

How close to the Sun would you have to be to hear it?

Is it unprofessional to mention your cover letter and resume are best viewed in Chrome?

How to efficiently shred a lot of cabbage?

What language is Raven using for her attack in the new 52?

Circle symbol compatible with square and triangle

What is my clock telling me to do?

How to foreshadow to avoid a 'deus ex machina'-construction

Exploiting the delay when a festival ticket is scanned



docker compose volume type - bind vs volume


How is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersHow to deal with persistent storage (e.g. databases) in DockerCopying files from Docker container to hostCopying files from host to Docker containerHow to copy Docker images from one host to another without using a repositoryDocker-compose overwriting package.json






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















TLDR



In docker-compose, whats the difference between



volumes:
- type: volume
source: mydata
target: /data


and



volumes:
- type: bind
source: mydata
target: /data


?



The question in long:



When you specify the volumes option in your docker-compose file, you can use the long-syntax style



According to the docs, the type option accepts 3 different values: volume, bind and tmpfs:



I understand the tmpfs option - it means that the volume will not be saved after the container is down..



But I fail to find any reference in the docs about the difference between the other 2 options: bind and volume, could someone enlighten me about that?










share|improve this question
































    4















    TLDR



    In docker-compose, whats the difference between



    volumes:
    - type: volume
    source: mydata
    target: /data


    and



    volumes:
    - type: bind
    source: mydata
    target: /data


    ?



    The question in long:



    When you specify the volumes option in your docker-compose file, you can use the long-syntax style



    According to the docs, the type option accepts 3 different values: volume, bind and tmpfs:



    I understand the tmpfs option - it means that the volume will not be saved after the container is down..



    But I fail to find any reference in the docs about the difference between the other 2 options: bind and volume, could someone enlighten me about that?










    share|improve this question




























      4












      4








      4








      TLDR



      In docker-compose, whats the difference between



      volumes:
      - type: volume
      source: mydata
      target: /data


      and



      volumes:
      - type: bind
      source: mydata
      target: /data


      ?



      The question in long:



      When you specify the volumes option in your docker-compose file, you can use the long-syntax style



      According to the docs, the type option accepts 3 different values: volume, bind and tmpfs:



      I understand the tmpfs option - it means that the volume will not be saved after the container is down..



      But I fail to find any reference in the docs about the difference between the other 2 options: bind and volume, could someone enlighten me about that?










      share|improve this question
















      TLDR



      In docker-compose, whats the difference between



      volumes:
      - type: volume
      source: mydata
      target: /data


      and



      volumes:
      - type: bind
      source: mydata
      target: /data


      ?



      The question in long:



      When you specify the volumes option in your docker-compose file, you can use the long-syntax style



      According to the docs, the type option accepts 3 different values: volume, bind and tmpfs:



      I understand the tmpfs option - it means that the volume will not be saved after the container is down..



      But I fail to find any reference in the docs about the difference between the other 2 options: bind and volume, could someone enlighten me about that?







      docker docker-compose docker-volume






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jun 30 at 14:24







      Efrat Levitan

















      asked Mar 26 at 21:22









      Efrat LevitanEfrat Levitan

      1,6381 gold badge3 silver badges18 bronze badges




      1,6381 gold badge3 silver badges18 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          4














          When bind mounts are files coming from your host machine, volumes are something more like the nas of docker.



          • Bind mounts are files mounted from your host machine (the one that runs your docker daemon) onto your container.

          • Volumes are like storage spaces totally managed by docker.

            You will find, in the literature, two types of volumes:

            • named volumes (you provide the name of it)

            • anonymous volumes (usual UUID names from docker, like you can find them on container or untagged images)


          Those volumes come with their own set of docker commands; you can also consult this list via



          docker volume --help


          You can see your existing volumes via



          docker volume ls


          You can create a named volume via



          docker volume create my_named_volume


          But you can also create a volume via a docker-compose file



          version: "3.3"

          services:
          mysql:
          image: mysql
          volumes:
          - type: volume
          source: db-data
          target: /var/lib/mysql/data

          volumes:
          db-data:


          Where this is the part saying please docker, mount me the volume named db-data on top of the container directory /var/lib/mysql/data



          - type: volume
          source: db-data
          target: /var/lib/mysql/data


          And this is the part saying to docker please create me a volume named db-data



          volumes:
          db-data:


          Docker documentation about the three mount types:



          • https://docs.docker.com/storage/bind-mounts/

          • https://docs.docker.com/storage/volumes/

          • https://docs.docker.com/storage/tmpfs/





          share|improve this answer



























          • thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

            – Efrat Levitan
            Mar 26 at 22:01











          • See the edited version of the answer. Especially the part where I speak about docker volume ls

            – b.enoit.be
            Mar 26 at 22:07











          • thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

            – Efrat Levitan
            Mar 26 at 22:11






          • 1





            None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

            – b.enoit.be
            Mar 26 at 22:16










          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%2f55366386%2fdocker-compose-volume-type-bind-vs-volume%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









          4














          When bind mounts are files coming from your host machine, volumes are something more like the nas of docker.



          • Bind mounts are files mounted from your host machine (the one that runs your docker daemon) onto your container.

          • Volumes are like storage spaces totally managed by docker.

            You will find, in the literature, two types of volumes:

            • named volumes (you provide the name of it)

            • anonymous volumes (usual UUID names from docker, like you can find them on container or untagged images)


          Those volumes come with their own set of docker commands; you can also consult this list via



          docker volume --help


          You can see your existing volumes via



          docker volume ls


          You can create a named volume via



          docker volume create my_named_volume


          But you can also create a volume via a docker-compose file



          version: "3.3"

          services:
          mysql:
          image: mysql
          volumes:
          - type: volume
          source: db-data
          target: /var/lib/mysql/data

          volumes:
          db-data:


          Where this is the part saying please docker, mount me the volume named db-data on top of the container directory /var/lib/mysql/data



          - type: volume
          source: db-data
          target: /var/lib/mysql/data


          And this is the part saying to docker please create me a volume named db-data



          volumes:
          db-data:


          Docker documentation about the three mount types:



          • https://docs.docker.com/storage/bind-mounts/

          • https://docs.docker.com/storage/volumes/

          • https://docs.docker.com/storage/tmpfs/





          share|improve this answer



























          • thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

            – Efrat Levitan
            Mar 26 at 22:01











          • See the edited version of the answer. Especially the part where I speak about docker volume ls

            – b.enoit.be
            Mar 26 at 22:07











          • thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

            – Efrat Levitan
            Mar 26 at 22:11






          • 1





            None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

            – b.enoit.be
            Mar 26 at 22:16















          4














          When bind mounts are files coming from your host machine, volumes are something more like the nas of docker.



          • Bind mounts are files mounted from your host machine (the one that runs your docker daemon) onto your container.

          • Volumes are like storage spaces totally managed by docker.

            You will find, in the literature, two types of volumes:

            • named volumes (you provide the name of it)

            • anonymous volumes (usual UUID names from docker, like you can find them on container or untagged images)


          Those volumes come with their own set of docker commands; you can also consult this list via



          docker volume --help


          You can see your existing volumes via



          docker volume ls


          You can create a named volume via



          docker volume create my_named_volume


          But you can also create a volume via a docker-compose file



          version: "3.3"

          services:
          mysql:
          image: mysql
          volumes:
          - type: volume
          source: db-data
          target: /var/lib/mysql/data

          volumes:
          db-data:


          Where this is the part saying please docker, mount me the volume named db-data on top of the container directory /var/lib/mysql/data



          - type: volume
          source: db-data
          target: /var/lib/mysql/data


          And this is the part saying to docker please create me a volume named db-data



          volumes:
          db-data:


          Docker documentation about the three mount types:



          • https://docs.docker.com/storage/bind-mounts/

          • https://docs.docker.com/storage/volumes/

          • https://docs.docker.com/storage/tmpfs/





          share|improve this answer



























          • thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

            – Efrat Levitan
            Mar 26 at 22:01











          • See the edited version of the answer. Especially the part where I speak about docker volume ls

            – b.enoit.be
            Mar 26 at 22:07











          • thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

            – Efrat Levitan
            Mar 26 at 22:11






          • 1





            None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

            – b.enoit.be
            Mar 26 at 22:16













          4












          4








          4







          When bind mounts are files coming from your host machine, volumes are something more like the nas of docker.



          • Bind mounts are files mounted from your host machine (the one that runs your docker daemon) onto your container.

          • Volumes are like storage spaces totally managed by docker.

            You will find, in the literature, two types of volumes:

            • named volumes (you provide the name of it)

            • anonymous volumes (usual UUID names from docker, like you can find them on container or untagged images)


          Those volumes come with their own set of docker commands; you can also consult this list via



          docker volume --help


          You can see your existing volumes via



          docker volume ls


          You can create a named volume via



          docker volume create my_named_volume


          But you can also create a volume via a docker-compose file



          version: "3.3"

          services:
          mysql:
          image: mysql
          volumes:
          - type: volume
          source: db-data
          target: /var/lib/mysql/data

          volumes:
          db-data:


          Where this is the part saying please docker, mount me the volume named db-data on top of the container directory /var/lib/mysql/data



          - type: volume
          source: db-data
          target: /var/lib/mysql/data


          And this is the part saying to docker please create me a volume named db-data



          volumes:
          db-data:


          Docker documentation about the three mount types:



          • https://docs.docker.com/storage/bind-mounts/

          • https://docs.docker.com/storage/volumes/

          • https://docs.docker.com/storage/tmpfs/





          share|improve this answer















          When bind mounts are files coming from your host machine, volumes are something more like the nas of docker.



          • Bind mounts are files mounted from your host machine (the one that runs your docker daemon) onto your container.

          • Volumes are like storage spaces totally managed by docker.

            You will find, in the literature, two types of volumes:

            • named volumes (you provide the name of it)

            • anonymous volumes (usual UUID names from docker, like you can find them on container or untagged images)


          Those volumes come with their own set of docker commands; you can also consult this list via



          docker volume --help


          You can see your existing volumes via



          docker volume ls


          You can create a named volume via



          docker volume create my_named_volume


          But you can also create a volume via a docker-compose file



          version: "3.3"

          services:
          mysql:
          image: mysql
          volumes:
          - type: volume
          source: db-data
          target: /var/lib/mysql/data

          volumes:
          db-data:


          Where this is the part saying please docker, mount me the volume named db-data on top of the container directory /var/lib/mysql/data



          - type: volume
          source: db-data
          target: /var/lib/mysql/data


          And this is the part saying to docker please create me a volume named db-data



          volumes:
          db-data:


          Docker documentation about the three mount types:



          • https://docs.docker.com/storage/bind-mounts/

          • https://docs.docker.com/storage/volumes/

          • https://docs.docker.com/storage/tmpfs/






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 22:24

























          answered Mar 26 at 21:50









          b.enoit.beb.enoit.be

          5,5944 gold badges28 silver badges42 bronze badges




          5,5944 gold badges28 silver badges42 bronze badges















          • thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

            – Efrat Levitan
            Mar 26 at 22:01











          • See the edited version of the answer. Especially the part where I speak about docker volume ls

            – b.enoit.be
            Mar 26 at 22:07











          • thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

            – Efrat Levitan
            Mar 26 at 22:11






          • 1





            None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

            – b.enoit.be
            Mar 26 at 22:16

















          • thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

            – Efrat Levitan
            Mar 26 at 22:01











          • See the edited version of the answer. Especially the part where I speak about docker volume ls

            – b.enoit.be
            Mar 26 at 22:07











          • thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

            – Efrat Levitan
            Mar 26 at 22:11






          • 1





            None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

            – b.enoit.be
            Mar 26 at 22:16
















          thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

          – Efrat Levitan
          Mar 26 at 22:01





          thanks, but im not sure i got the volume option - what exactly happens when i declare a volume of this type?

          – Efrat Levitan
          Mar 26 at 22:01













          See the edited version of the answer. Especially the part where I speak about docker volume ls

          – b.enoit.be
          Mar 26 at 22:07





          See the edited version of the answer. Especially the part where I speak about docker volume ls

          – b.enoit.be
          Mar 26 at 22:07













          thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

          – Efrat Levitan
          Mar 26 at 22:11





          thanks, its getting cleared now. can you also tell me, when i use the short-syntax style in my volume (path:path), to which option does the type defaults to?

          – Efrat Levitan
          Mar 26 at 22:11




          1




          1





          None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

          – b.enoit.be
          Mar 26 at 22:16





          None. Or actually, both. Docker is getting clever about it. If it gets a /pat/to/file it will be a bind. If it gets a ./relative/path/to/file also, if it is just a name then docker understand it is a volume

          – b.enoit.be
          Mar 26 at 22:16








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          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%2f55366386%2fdocker-compose-volume-type-bind-vs-volume%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript