Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

371
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?

over 4 years 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.

over 4 years 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 $*
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!