{"id":2607,"date":"2020-11-16T11:14:54","date_gmt":"2020-11-16T10:14:54","guid":{"rendered":"https:\/\/geko2.factoryfy.com\/nfs-volumes-in-docker-containers\/"},"modified":"2021-11-03T18:51:20","modified_gmt":"2021-11-03T17:51:20","slug":"nfs-volumes-docker-containers","status":"publish","type":"post","link":"https:\/\/geko.cloud\/en\/nfs-volumes-docker-containers\/","title":{"rendered":"NFS volumes in Docker containers"},"content":{"rendered":"<p>In many cases we find ourselves<strong> using a volume in the docker that is shared from another server via NFS<\/strong>. For this purpose, the docker includes its own NFS driver that will allow us to use this volume directly without having to run it on the host machine.<\/p>\n<p>We have\u00a0different options when using these NFS volumes in our containers:<\/p>\n<ul>\n<li><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Firstly, we can create a volume that we can use either in <strong>docker compose<\/strong> or using a <strong>docker run<\/strong>. This is the reason why we will use the following command:\u00a0<\/span><\/span>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{\">  $ docker volume create --driver local \r\n      --opt type=nfs \r\n      --opt o=nfsvers=4,addr=nfs.example-domain.com,rw \r\n      --opt device=:\/path\/to\/dir \r\n      volume-name<\/pre>\n<\/div>\n<p><span style=\"font-weight: 400;\"><span style=\"font-weight: 400;\"> Once we have created the volume, we can mount it inside our container:<\/span><\/span><\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{\">  $ docker run -it --rm \r\n    --mount type=volume,dst=\/container\/path,volume-driver=local,volume-opt=type=nfs,\"volume-opt=o=nfsvers=4,addr=nfs.example-domain.com\",volume-opt=device=:\/host\/path \r\n    volume-name<\/pre>\n<\/div>\n<\/li>\n<li>The same configuration <strong>can be applied within our docker-comper<\/strong>. Inside our <strong>docker-compose.yaml<\/strong> we will have to create the volume and mount it inside our container.\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{\"># Container conf\r\n  ...\r\n  container-conf:\r\n    container_name: foo\/bar\r\n    image: imagename:tag\r\n    ports:\r\n      - 80:80\r\n    volumes:\r\n      - new_volume:\/path\/inside\/container\r\n  ...\r\n# Create volume\r\n  ...\r\n  volumes:\r\n    new_volume:\r\n      driver: local\r\n      driver_opts:\r\n        type: nfs\r\n        o: nfsvers=4,addr=nfs.example-domain.com,rw\r\n        device: \":\/host\/path\/to\/dir\"\r\n  ...<\/pre>\n<\/div>\n<p>We have found ourselves in the same situation needing to fit the container with an <strong>EFS<\/strong> (Elastic File System) from Amazon Web Services. This AWS service provides scalable, elastic and concurrent storage and we will be able to add it using the same NFS docker driver.<\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{\"># Container conf\r\n ...\r\n  container-conf:\r\n    container_name: foo\/bar\r\n    image: imagename:tag\r\n    ports:\r\n      - 80:80\r\n    volumes:\r\n      - new_volume:\/path\/inside\/container\r\n ... \r\n# Create volume\r\n ...\r\n  volumes:\r\n    efs_volume:\r\n      driver: local\r\n      driver_opts:\r\n        type: nfs\r\n        o: addr=[EFS_DNS],nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2\r\n        device: [EFS_DNS]:\/\r\n ...<\/pre>\n<\/div>\n<p>Please note that if you have just created this EFS, it may be that <strong>when you try to create this volume you will get an error warning that you cannot find the EFS endpoint<\/strong>. This is due to the fact that these DNS will take a few minutes to propagate. If you cannot add it via the endpoint, you can do it directly from the EFS&#8217;s IP.<\/li>\n<\/ul>\n<p>We hope that this information has been useful to you and don&#8217;t forget that at <a href=\"https:\/\/geko.cloud\/en\/\">Geko cloud<\/a> we are at your disposal for the management of <a href=\"https:\/\/geko.cloud\/en\/cloud-services\/cloud-management\/\">cloud infrastructures<\/a> and microservices.<\/p>\n<p>If you have other questions related to <a href=\"https:\/\/geko.cloud\/en\/cloud-services\/microservices-architecture-docker\/\">docker<\/a> or <a href=\"https:\/\/geko.cloud\/en\/what-is-kubernetes\/\">Kubernetes<\/a>, perhaps you can find answers in other posts on our <a href=\"https:\/\/geko.cloud\/en\/blog\/\">blog<\/a>.<\/p>\n<p>See you next time!<\/p>\n<h4 style=\"text-align: center;\"><a href=\"https:\/\/geko.cloud\/en\/contact\/\">Contact us and let&#8217;s talk about how we could help you make your platform more agile and secure!<\/a><\/h4>\n<p><a href=\"https:\/\/geko.cloud\/en\/contact\/\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3265\" src=\"https:\/\/geko2.factoryfy.com\/wp-content\/uploads\/geko-1-300x297.png\" alt=\"\" width=\"69\" height=\"68\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In many cases we find ourselves using a volume in the docker that is shared from another server via NFS. For this purpose, the docker includes its own NFS driver that will allow us to use this volume directly without having to run it on the host machine. We have\u00a0different options when using these NFS [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2153,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[67],"tags":[72,74],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>NFS volumes in Docker containers - Geko Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to create NFS volumes in Docker containers step by step in our post written by Kubernetes and Docker experts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NFS volumes in Docker containers - Geko Cloud\" \/>\n<meta property=\"og:description\" content=\"Learn how to create NFS volumes in Docker containers step by step in our post written by Kubernetes and Docker experts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\" \/>\n<meta property=\"og:site_name\" content=\"Geko Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-16T10:14:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-03T17:51:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jose Luis S\u00e1nchez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@geko_cloud\" \/>\n<meta name=\"twitter:site\" content=\"@geko_cloud\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\"},\"author\":{\"name\":\"Jose Luis S\u00e1nchez\",\"@id\":\"https:\/\/geko.cloud\/es\/#\/schema\/person\/d06aff498ebfbc75b5010ebe92af41ed\"},\"headline\":\"NFS volumes in Docker containers\",\"datePublished\":\"2020-11-16T10:14:54+00:00\",\"dateModified\":\"2021-11-03T17:51:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\"},\"wordCount\":320,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/geko.cloud\/es\/#organization\"},\"image\":{\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png\",\"keywords\":[\"AWS\",\"Docker\"],\"articleSection\":[\"Labs\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\",\"url\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\",\"name\":\"NFS volumes in Docker containers - Geko Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/geko.cloud\/es\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png\",\"datePublished\":\"2020-11-16T10:14:54+00:00\",\"dateModified\":\"2021-11-03T17:51:20+00:00\",\"description\":\"Learn how to create NFS volumes in Docker containers step by step in our post written by Kubernetes and Docker experts.\",\"breadcrumb\":{\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage\",\"url\":\"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png\",\"contentUrl\":\"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png\",\"width\":1100,\"height\":400,\"caption\":\"docker nfs logo\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/geko.cloud\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"NFS volumes in Docker containers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/geko.cloud\/es\/#website\",\"url\":\"https:\/\/geko.cloud\/es\/\",\"name\":\"Geko Cloud\",\"description\":\"Servicios de consultor\u00eda cloud y devops\",\"publisher\":{\"@id\":\"https:\/\/geko.cloud\/es\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/geko.cloud\/es\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/geko.cloud\/es\/#organization\",\"name\":\"Geko Cloud\",\"url\":\"https:\/\/geko.cloud\/es\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/geko.cloud\/es\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/geko.cloud\/wp-content\/uploads\/2021\/10\/geko_logo-positivo.png\",\"contentUrl\":\"https:\/\/geko.cloud\/wp-content\/uploads\/2021\/10\/geko_logo-positivo.png\",\"width\":1650,\"height\":809,\"caption\":\"Geko Cloud\"},\"image\":{\"@id\":\"https:\/\/geko.cloud\/es\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/geko_cloud\",\"https:\/\/www.instagram.com\/gekocloud\/\",\"https:\/\/www.linkedin.com\/company\/gekocloud\",\"https:\/\/www.youtube.com\/channel\/UC5EFLCqUM7fEaXSa_0nWowQ\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/geko.cloud\/es\/#\/schema\/person\/d06aff498ebfbc75b5010ebe92af41ed\",\"name\":\"Jose Luis S\u00e1nchez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/geko.cloud\/es\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ebfd055d4dba456220c682523fcc237c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ebfd055d4dba456220c682523fcc237c?s=96&d=mm&r=g\",\"caption\":\"Jose Luis S\u00e1nchez\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"NFS volumes in Docker containers - Geko Cloud","description":"Learn how to create NFS volumes in Docker containers step by step in our post written by Kubernetes and Docker experts.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/","og_locale":"en_US","og_type":"article","og_title":"NFS volumes in Docker containers - Geko Cloud","og_description":"Learn how to create NFS volumes in Docker containers step by step in our post written by Kubernetes and Docker experts.","og_url":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/","og_site_name":"Geko Cloud","article_published_time":"2020-11-16T10:14:54+00:00","article_modified_time":"2021-11-03T17:51:20+00:00","og_image":[{"width":1100,"height":400,"url":"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png","type":"image\/png"}],"author":"Jose Luis S\u00e1nchez","twitter_card":"summary_large_image","twitter_creator":"@geko_cloud","twitter_site":"@geko_cloud","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#article","isPartOf":{"@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/"},"author":{"name":"Jose Luis S\u00e1nchez","@id":"https:\/\/geko.cloud\/es\/#\/schema\/person\/d06aff498ebfbc75b5010ebe92af41ed"},"headline":"NFS volumes in Docker containers","datePublished":"2020-11-16T10:14:54+00:00","dateModified":"2021-11-03T17:51:20+00:00","mainEntityOfPage":{"@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/"},"wordCount":320,"commentCount":0,"publisher":{"@id":"https:\/\/geko.cloud\/es\/#organization"},"image":{"@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage"},"thumbnailUrl":"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png","keywords":["AWS","Docker"],"articleSection":["Labs"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/","url":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/","name":"NFS volumes in Docker containers - Geko Cloud","isPartOf":{"@id":"https:\/\/geko.cloud\/es\/#website"},"primaryImageOfPage":{"@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage"},"image":{"@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage"},"thumbnailUrl":"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png","datePublished":"2020-11-16T10:14:54+00:00","dateModified":"2021-11-03T17:51:20+00:00","description":"Learn how to create NFS volumes in Docker containers step by step in our post written by Kubernetes and Docker experts.","breadcrumb":{"@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#primaryimage","url":"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png","contentUrl":"https:\/\/geko.cloud\/wp-content\/uploads\/portada.png","width":1100,"height":400,"caption":"docker nfs logo"},{"@type":"BreadcrumbList","@id":"https:\/\/geko.cloud\/es\/volumenes-nfs-contenedores-docker\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/geko.cloud\/en\/"},{"@type":"ListItem","position":2,"name":"NFS volumes in Docker containers"}]},{"@type":"WebSite","@id":"https:\/\/geko.cloud\/es\/#website","url":"https:\/\/geko.cloud\/es\/","name":"Geko Cloud","description":"Servicios de consultor\u00eda cloud y devops","publisher":{"@id":"https:\/\/geko.cloud\/es\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/geko.cloud\/es\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/geko.cloud\/es\/#organization","name":"Geko Cloud","url":"https:\/\/geko.cloud\/es\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/geko.cloud\/es\/#\/schema\/logo\/image\/","url":"https:\/\/geko.cloud\/wp-content\/uploads\/2021\/10\/geko_logo-positivo.png","contentUrl":"https:\/\/geko.cloud\/wp-content\/uploads\/2021\/10\/geko_logo-positivo.png","width":1650,"height":809,"caption":"Geko Cloud"},"image":{"@id":"https:\/\/geko.cloud\/es\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/geko_cloud","https:\/\/www.instagram.com\/gekocloud\/","https:\/\/www.linkedin.com\/company\/gekocloud","https:\/\/www.youtube.com\/channel\/UC5EFLCqUM7fEaXSa_0nWowQ"]},{"@type":"Person","@id":"https:\/\/geko.cloud\/es\/#\/schema\/person\/d06aff498ebfbc75b5010ebe92af41ed","name":"Jose Luis S\u00e1nchez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/geko.cloud\/es\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ebfd055d4dba456220c682523fcc237c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ebfd055d4dba456220c682523fcc237c?s=96&d=mm&r=g","caption":"Jose Luis S\u00e1nchez"}}]}},"_links":{"self":[{"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/posts\/2607"}],"collection":[{"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/comments?post=2607"}],"version-history":[{"count":3,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/posts\/2607\/revisions"}],"predecessor-version":[{"id":5257,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/posts\/2607\/revisions\/5257"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/media\/2153"}],"wp:attachment":[{"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/media?parent=2607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/categories?post=2607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geko.cloud\/en\/wp-json\/wp\/v2\/tags?post=2607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}