Linux使用git安装docker脚本
时间: 2023-05-28 20:05:41 浏览: 69
以下是Linux使用git安装docker脚本的步骤:
1. 打开终端并运行以下命令,以安装git:
```
sudo apt-get update
sudo apt-get install git
```
2. 运行以下命令以克隆docker安装脚本:
```
git clone https://github.com/docker/docker-install.git
```
3. 进入docker-install目录并运行以下命令以安装docker:
```
cd docker-install
sudo ./install.sh
```
4. 等待安装完成后,运行以下命令以启动docker服务:
```
sudo systemctl start docker
```
5. 运行以下命令以验证docker是否已正确安装:
```
sudo docker run hello-world
```
如果输出以下信息,则表示docker已成功安装:
```
Hello from Docker!
This message shows that your installation appears to be working correctly.
```
相关问题
写一个linux系统配置初始化脚本
这个问题涉及到的内容比较多,因为不同的人需要不同的初始化脚本。以下是一个简单的例子,用于对Ubuntu 18.04系统进行基本的初始化:
```
#!/bin/bash
# 更新系统
sudo apt update
sudo apt upgrade
# 安装常用工具
sudo apt install vim curl wget git
# 配置Git
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
# 安装Node.js
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejs
# 安装Docker
sudo apt install -y docker.io
# 配置Docker
sudo usermod -aG docker $USER
# 安装Docker Compose
sudo apt install -y docker-compose
# 安装Nginx
sudo apt install -y nginx
# 启动Nginx
sudo systemctl start nginx
# 设置Nginx开机自启动
sudo systemctl enable nginx
```
这个脚本做了以下事情:
1. 更新系统和安装常用工具。
2. 配置Git的用户名和邮箱。
3. 安装Node.js。
4. 安装Docker和Docker Compose,并配置当前用户为Docker组的成员。
5. 安装Nginx,并启动Nginx,并设置开机自启动。
当然,这只是一个简单的例子,不同的人需要不同的配置。你可以根据自己的需要,修改或增加脚本中的命令。
linux iptables脚本
下面是一个简单的iptables脚本,可以阻止所有入站流量,允许所有出站流量:
```
#!/bin/bash
# 清空所有规则
iptables -F
# 设置默认策略
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# 允许回环接口(localhost)
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# 允许已经建立的连接
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# 允许ssh连接
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# 允许ping
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
# 允许HTTP和HTTPS连接
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# 防止DOS攻击
iptables -A INPUT -p tcp --dport 80 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
# 允许DNS查询
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
# 允许NTP时间同步
iptables -A INPUT -p udp --dport 123 -j ACCEPT
# 允许SMTP邮件
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
# 允许POP3邮件
iptables -A INPUT -p tcp --dport 110 -j ACCEPT
# 允许IMAP邮件
iptables -A INPUT -p tcp --dport 143 -j ACCEPT
# 允许FTP连接
iptables -A INPUT -p tcp --dport 20:21 -j ACCEPT
# 允许MySQL连接
iptables -A INPUT -p tcp --dport 3306 -j ACCEPT
# 允许SSH连接
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# 允许Git连接
iptables -A INPUT -p tcp --dport 9418 -j ACCEPT
# 允许SVN连接
iptables -A INPUT -p tcp --dport 3690 -j ACCEPT
# 允许Redis连接
iptables -A INPUT -p tcp --dport 6379 -j ACCEPT
# 允许Memcached连接
iptables -A INPUT -p tcp --dport 11211 -j ACCEPT
# 允许MongoDB连接
iptables -A INPUT -p tcp --dport 27017 -j ACCEPT
# 允许Elasticsearch连接
iptables -A INPUT -p tcp --dport 9200 -j ACCEPT
iptables -A INPUT -p tcp --dport 9300 -j ACCEPT
# 允许Zookeeper连接
iptables -A INPUT -p tcp --dport 2181 -j ACCEPT
# 允许Kafka连接
iptables -A INPUT -p tcp --dport 9092 -j ACCEPT
# 允许Kibana连接
iptables -A INPUT -p tcp --dport 5601 -j ACCEPT
# 允许RabbitMQ连接
iptables -A INPUT -p tcp --dport 5672 -j ACCEPT
# 允许Zabbix连接
iptables -A INPUT -p tcp --dport 10050 -j ACCEPT
# 允许Prometheus连接
iptables -A INPUT -p tcp --dport 9090 -j ACCEPT
# 允许Grafana连接
iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
# 允许Jenkins连接
iptables -A INPUT -p tcp --dport 8080 -j ACCEPT
# 允许Docker连接
iptables -A INPUT -p tcp --dport 2375 -j ACCEPT
iptables -A INPUT -p tcp --dport 2376 -j ACCEPT
# 保存规则
iptables-save > /etc/sysconfig/iptables
```
这个脚本假定你的系统默认是没有任何防火墙规则的。如果你已经有一些防火墙规则,那么需要根据实际情况进行修改。