Instructions for using the --rm option of docker run

Instructions for using the --rm option of docker run

When the Docker container exits, the file system inside the default container is still retained to facilitate debugging and preserve user data.

However, for the foreground container, since it only runs for a short period of time during the development and debugging process, there is no need to retain its user data. Therefore, you can set the --rm option when starting the container, so that the file system inside the container can be automatically cleaned up when the container exits.

Here is an example:

docker run --rm ba-208

Equivalent to

docker run --rm=true ba-208

Obviously, the --rm option cannot be used together with the -d option (or it does not make sense to use them together), that is, it can only automatically clean up the foreground container, not the detached container.

Note that the --rm option will also clean up the container's anonymous data volumes.

Therefore, executing the docker run command with the --rm command option is equivalent to executing docker rm -v after the container exits.

Additional knowledge: Use the docker run --cap-add parameter to solve permission issues (unable to use gdb debugging, unable to use date -s to modify time)

Problem: Cannot use gdb debugging on centos in docker container

ptrace: Operation not permitted

Solution reference: Click to enter

Add the parameter --cap-add=SYS_PTRACE to the docker run command

docker run --cap-add=SYS_PTRACE ......

For more caps, see the manual

http://man7.org/linux/man-pages/man7/capabilities.7.html

There is also a less elegant approach that is not recommended: solve it with –privileged –privileged is equivalent to –cap-add=ALL.

A similar problem is that date -s cannot be used to modify the time on the docker machine

Solution:

docker run --cap-add=SYS_TIME --cap-add=SYS_PTRACE ...

The above instructions for using the --rm option of docker run are all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Solution to the problem of insufficient storage resource pool of Docker server
  • Detailed explanation of the solution to docker-compose being too slow
  • Solve the problem of not being able to enter breakpoints when using GDB in Docker

<<:  HTML form_PowerNode Java Academy

>>:  Vue implements dynamic routing details

Recommend

MySQL online deadlock analysis practice

Preface I believe that everyone has had a simple ...

Solve MySQL login error: 'Access denied for user 'root'@'localhost'

First of all, I don't know why I can't lo...

JS 9 Promise Interview Questions

Table of contents 1. Multiple .catch 2. Multiple ...

VMware Workstation 15 Pro Installation Guide (for Beginners)

01. VMware Workstation Pro 15 Download Download: ...

Two tools for splitting the screen in the Linux command line terminal

Here are two terminal split screen tools: screen ...

A brief discussion on the principle of shallow entry and deep exit of MySQL

Table of contents 1. Overview of the page 2. Infi...

The correct way to use Homebrew in Linux

Many people use Linux Homebrew. Here are three ti...

Installing Windows Server 2008 operating system on a virtual machine

This article introduces the installation of Windo...

js memory leak scenarios, how to monitor and analyze them in detail

Table of contents Preface What situations can cau...

Reasons and solutions for MySQL selecting the wrong index

In MySQL, you can specify multiple indexes for a ...

Summary of considerations for writing web front-end code

1. It is best to add a sentence like this before t...