Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

138
Views
protect docker container and\or volume from accidental deletion

we have a docker container (mongodb) we are using, with volume mount to store data persistently.

I would like to protect the container and\or volume from accidental deletion by commands 'docker volume prune' or even just 'docker volume rm'

any suggestion?

9 months ago · Santiago Trujillo
2 answers
Answer question

0

To prevent accidental deletion of container/volume, there is no any in-built way provided by docker for it.

Check this out.

Also there was a code change to have this feature as mentioned here but it was voted against by solomon hykes because of few reasons.


But there is way to prevent accidental volume deletion while using docker volume prune.

Check this out.

Hope this helps.

9 months ago · Santiago Trujillo Report

0

Create a function / alias in the bash profile or bashrc.

function docker {
  docker_vol_res="Y"
  [[ $1 == vol* ]] && [[ $2 == prune || $2 == rm ]] && echo -n "Do you want to \"$2\" the volume (Y/N)? " && read docker_vol_res
  [[ $docker_vol_res == "Y" ]] && /usr/bin/docker $*
}
9 months ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.