有时候我们需要进入docker容器时以root身份进入,这边汇总了两种方式如下

第一种

docker exec -it --user=root container_id /bin/bash

第二种

docker exec -u 0 -it  container_id  /bin/bash