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

JavaScript's unreliable undefined

undefined In JavaScript, if we want to determine ...

HTML+CSS+JavaScript to create a simple tic-tac-toe game

Table of contents Implementing HTML Add CSS Imple...

Talk about how to identify HTML escape characters through code

Occasionally you'll see characters such as &#...

Use of js optional chaining operator

Preface The optional chaining operator (?.) allow...

Detailed explanation of CSS3+JS perfect implementation of magnifying glass mode

About a year ago, I wrote an article: Analysis of...

Linux platform mysql enable remote login

During the development process, I often encounter...

How to store images in MySQL

1 Introduction When designing a database, it is i...

An article to help you understand jQuery animation

Table of contents 1. Control the display and hidi...

Summary of common optimization operations of MySQL database (experience sharing)

Preface For a data-centric application, the quali...

Nodejs uses readline to prompt for content input example code

Table of contents Preface 1. bat executes js 2. T...

CentOS 6.5 installation mysql5.7 tutorial

1. New Features MySQL 5.7 is an exciting mileston...

Mysql date formatting and complex date range query

Table of contents Preface Query usage scenario ca...

An audio-visual Linux distribution that appeals to audiophiles

I recently stumbled upon the Audiovisual Linux Pr...