Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Init for Docker Containers

** Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement! **

Built-in Support

Docker has built-in support for init process (which is based on tini) now. In short, you just have to specify the option --init when you start a container using …

Hands on the Python module subprocess

General Tips

  1. The method subprocess.run is preferred over older high-level APIs (subprocess.call, subprocess.check_call and subprocess.check_output). The method subprocess.Popen (which powers the high-level APIs) can be used if you need advanced controls. When running a shell command using subprocess.run,

    1. Avoid using system shell (i.e., avoid using shell=True) for 2 reasons. First, avoid shell injection attack. Second, there is no need for you to manually escape special characters in the command.