Kill inside the container after the process

Let Docker use more convenient Exec

  • We are in the process of applying the container, whether it is in the process of building a mirror through the Dockerfile process, or the container to run for a period of time to see the internal structure, we still hope to operate the local machine, real-time view container internal files, code or log The Or modify the file, copy the file directory and so on.
  • There are two ways to access the inside of the container
    1. Docker comes with the exec command
    2. 2. Nsenter tool

  • Talk about the Docker exec command mode
    1.png
  • As shown in the figure, the simple ls command. Linux system comes with the command can be run in this way. The wrong location of the document, mv look at the log , on the cat log.log about, and so on.

Exec added

  • Simple operation can not satisfy our curiosity to him …
  • We run the docker exec -ti 61f ps -ef
    2.png
  • Found only 3 processes, process 1 is the CMD command to start the script; process 2 is the script to start the process; process 3 is the process we run ps -ef.
  • Out of curiosity, i docker exec 9fe0 kill 15
    3.png
  • The container has stopped …
  • The reason is that after killing the process, Dockerfile specified CMD ["/ run.sh"] script is running, the CMD entry has been exited, causing the container to exit.

The problem is not over yet

  • Kubernetes is a docker-based container cluster management system. One of its major features is the ability to have a Replication Controllers whose role is to keep the number of pods started (the pod is loaded with a container). I guess if a similar kill off the container inside the process, then kubernetes should let the container restart. So come to try.
  • At that time they applied kubernetes, and provided the client tce can use the exec function. Run tce exec bbb-145fv-zkdqz ps -ef
    4.png
  • tce exec bbb-145fv-zkdqz kill 15
    5.png
    Did not restart? ?
  • Run again tce exec bbb-145fv-zkdqz ps -ef
    6.png
  • Appeared again.
  • This shows that Kubernentes' Replication Controllers are still very powerful. To ensure that the specified number of pod copies in the cluster are running.

Author brief introduction: Ding Qiwei, speed cloud software engineer.

    Heads up! This alert needs your attention, but it's not super important.