DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Using Docker Volume Plugins with Amazon ECS-Optimized AMI

Using Docker Volume Plugins with Amazon ECS-Optimized AMI

Here are 5 short steps to use volume plugins with Docker while using the Amazon ECS-optimized AMI.

Jeremy Unruh user avatar by
Jeremy Unruh
·
Nov. 10, 15 · Tutorial
Like (2)
Save
Tweet
Share
3.50K Views

Join the DZone community and get the full member experience.

Join For Free

Amazon EC2 Container Service (ECS) is a highly scalable, high performance container management services that supports Docker containers.

If you want to use volume plugins with Docker and are using the Amazon ECS-optimized AMI you will need to make some modification in order to successfully mount external volumes within a container.

By default the init.d script for docker makes mount namespaces unshared in the kernel. Basically mounting and unmounting filesystems will not affect the rest of the system when this is enabled.  Volume plugins mount external systems on the container host itself and then automatically associate it to the volume mount target within the container.  This is considered sharing which  is why we need to fix the init.d script in order to use volume plugins.

Fixing the Docker init.d script

  1. As sudo open the /etc/init.d/docker file in your favorite editor on the ECS container host.
  2. Locate the start() function  and fine the "$unshare" -m -- nohup $exec -d ${OPTIONS} ... line below it.
  3. Remove the following from that line: "$unshare" -m --
  4. The remaining execution should look something like:
    nohup $exec -d ${OPTIONS} ${DOCKER_STORAGE_OPTIONS} &>> $logfile &
  5. Save and restart the docker service

You should now be able to use any volume plugin to mount/unmount external storage within a Docker container.

For more information about volume plugins: https://docs.docker.com/extend/plugins/

To mount NFS, EFS or CIFS volumes in Docker see: https://github.com/gondor/docker-volume-netshare

Docker (software) Amazon Machine Image

Published at DZone with permission of Jeremy Unruh, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Express Hibernate Queries as Type-Safe Java Streams
  • ChatGPT: The Unexpected API Test Automation Help
  • AWS Cloud Migration: Best Practices and Pitfalls to Avoid
  • How to Secure Your CI/CD Pipeline

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: