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

N ways to align the last row of lists in CSS flex layout to the left (summary)

I would like to quote an article by Zhang Xinxu a...

MySql index detailed introduction and correct use method

MySql index detailed introduction and correct use...

Detailed explanation of the use of Refs in React's three major attributes

Table of contents Class Component Functional Comp...

Nginx tp3.2.3 404 problem solution

Recently I changed Apache to nginx. When I moved ...

Writing a web calculator using javascript

This article mainly records the effect of using j...

Implementing login page based on layui

This article example shares the specific code of ...

Simple steps to write custom instructions in Vue3.0

Preface Vue provides a wealth of built-in directi...

Detailed tutorial for installing mysql5.7.21 under Windows system

MySQL Installer provides an easy-to-use, wizard-b...

MySQL data migration using MySQLdump command

The advantages of this solution are simplicity an...

Analysis of statement execution order of sql and MySQL

I encountered a problem today: Can I use the as a...

A brief discussion on Axios's solution to remove duplicate requests

Table of contents 1. Cancel duplicate requests 2....

Detailed explanation of Vue's hash jump principle

Table of contents The difference between hash and...

Docker case analysis: Building a MySQL database service

Table of contents 1 Create configuration and data...

MySQL sharding details

1. Business scenario introduction Suppose there i...