
# 卸载ASM-PROXY
如果已完成虚拟机治理任务，可以将其中的ASM-PROXY卸载，释放资源。
#### 删除已添加的iptables规则
1. 以root用户登录虚拟机。
2. 执行以下命令删除添加的istio iptables规则。 
   **iptables -t nat -D PREROUTING -p tcp -j ISTIO_INBOUND**
   **iptables -t nat -D OUTPUT -p tcp -j ISTIO_OUTPUT**
   **iptables -t nat -F ISTIO_OUTPUT**
   **iptables -t nat -X ISTIO_OUTPUT**
   **iptables -t nat -F ISTIO_INBOUND**
   **iptables -t nat -X ISTIO_INBOUND**
   **iptables -t nat -F ISTIO_REDIRECT**
   **iptables -t nat -X ISTIO_REDIRECT**
   **iptables -t nat -F ISTIO_IN_REDIRECT**
   **iptables -t nat -X ISTIO_IN_REDIRECT**
   **iptables-save**
   
   
3. 执行以下命令查看虚拟机当前的iptables规则。 
   **iptables -t nat -L -v**
   回显如下，可以看到istio相关规则已经清除。
   ```
   Chain PREROUTING (policy ACCEPT 2 packets, 104 bytes)
    pkts bytes target     prot opt in     out     source               destination         
      47  2498 DOCKER     all  --  any    any     anywhere             anywhere             ADDRTYPE match dst-type LOCAL
   Chain INPUT (policy ACCEPT 2 packets, 104 bytes)
    pkts bytes target     prot opt in     out     source               destination         
   Chain OUTPUT (policy ACCEPT 5 packets, 350 bytes)
    pkts bytes target     prot opt in     out     source               destination         
       0     0 DOCKER     all  --  any    any     anywhere            !localhost/8          ADDRTYPE match dst-type LOCAL
   Chain POSTROUTING (policy ACCEPT 5 packets, 350 bytes)
    pkts bytes target     prot opt in     out     source               destination         
       0     0 MASQUERADE  all  --  any    !docker0  172.17.0.0/16        anywhere            
   Chain DOCKER (2 references)
    pkts bytes target     prot opt in     out     source               destination         
   0     0 RETURN     all  --  docker0 any     anywhere             anywhere
   ```
   
   
 
#### 卸载容器
1. 在虚拟机上执行以下命令，获取asm-proxy容器ID。
   
   **docker ps \| grep asm-proxy**
   回显第一列为asm-proxy容器的ID。
   ```
   46afed024f46    asm-proxy:1.8.4    "/usr/bin/bash /usr/..."    2 days ago    Up 2 days       asm-proxy
   ```
   
   
2. 执行以下命令，停止asm-proxy容器。 
   **docker rm -f** *xxx*
   其中，*xxx* 为[1]获取的asm-proxy容器ID。
   
   
 
