页面“Linux病毒查杀clamav”与“Docker修改hosts方法”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(创建页面,内容为“=install= ==debian== sudo apt-get install clamav clamav-daemon clamtk #Graphical User Interface [https://www.poftut.com/how-to-install-and-use-clamav-antivi…”)
 
→‎1
 
第1行: 第1行:
=install=
+
=1=
==debian==
+
直接进入容器中修改/etc/hosts
sudo apt-get install clamav clamav-daemon  clamtk #Graphical User Interface
 
  
 +
缺点:重启容器后,增加的内容会丢失
 +
<pre>
  
 +
NS1=apisns..com
 +
NS2=webappsns..com
  
  
 +
docker exec -i docker-compose-nuxt_nuxt-pc_1 sh -c "echo '114.55.202.3 ${NS1}'>>/etc/hosts"
 +
docker exec -i docker-compose-nuxt_nuxt-pc_1 sh -c "echo '114.55.202.3 ${NS2}'>>/etc/hosts"
  
 +
docker exec -i docker-compose-nuxt_nuxt-pc_1 sh -c "cat /etc/hosts" 
  
[https://www.poftut.com/how-to-install-and-use-clamav-antivirus-software-in-linux-ubuntu-debian-mint-kali-fedora-centos-rhel/ How To Install and Use ClamAV Antivirus Software In Linux, Ubuntu, Debian, Mint, Kali, Fedora, CentOS, RHEL]
+
 
 +
如何还原hosts
 +
 
 +
cd /data/docker-compose-nuxt/
 +
docker-compose down && docker-compose up -d
 +
 
 +
</pre>
 +
 
 +
=2=
 +
<pre>
 +
在docker-compose.yml文件中,通过配置参数extra_hosts实现。例如:
 +
 
 +
extra_hosts:
 +
- "somehost:162.242.195.82"
 +
- "otherhost:50.31.209.229
 +
</pre>
 +
 
 +
=3=
 +
通过参数 --add-host来添加域名和IP信息到容器的/etc/hosts文
 +
  docker run --add-host=myhostname:10.180.8.1 --name test -it debian
 +
[[category:container]]

2020年9月24日 (四) 09:57的版本

1

直接进入容器中修改/etc/hosts

缺点:重启容器后,增加的内容会丢失


NS1=apisns..com
NS2=webappsns..com


docker exec -i docker-compose-nuxt_nuxt-pc_1 sh -c "echo '114.55.202.3 ${NS1}'>>/etc/hosts"
docker exec -i docker-compose-nuxt_nuxt-pc_1 sh -c "echo '114.55.202.3 ${NS2}'>>/etc/hosts"

docker exec -i docker-compose-nuxt_nuxt-pc_1 sh -c "cat /etc/hosts"  


如何还原hosts

cd /data/docker-compose-nuxt/
docker-compose down && docker-compose up -d

2

在docker-compose.yml文件中,通过配置参数extra_hosts实现。例如:

extra_hosts:
 - "somehost:162.242.195.82"
 - "otherhost:50.31.209.229

3

通过参数 --add-host来添加域名和IP信息到容器的/etc/hosts文

 docker run --add-host=myhostname:10.180.8.1 --name test -it debian