更新docker 文档
This commit is contained in:
parent
78612e55a7
commit
46c343c1d6
@ -1,8 +1,7 @@
|
|||||||
|
# centos 安装 docker
|
||||||
|
|
||||||
# Linux 安装 Docker
|
# Linux 安装 Docker
|
||||||
|
|
||||||
|
|
||||||
## 安装脚本
|
## 安装脚本
|
||||||
|
|
||||||
一键安装脚本!Linux系统都支持!
|
一键安装脚本!Linux系统都支持!
|
||||||
@ -11,7 +10,7 @@
|
|||||||
curl -sSL https://get.docker.com/ | sh
|
curl -sSL https://get.docker.com/ | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
## oracle linxu
|
## oracle linxu
|
||||||
|
|
||||||
1. 执行以下命令,以安装Docker依赖项:
|
1. 执行以下命令,以安装Docker依赖项:
|
||||||
|
|
||||||
@ -42,8 +41,6 @@ sudo systemctl enable docker
|
|||||||
|
|
||||||
希望这次能给您提供一个更简洁的方法。
|
希望这次能给您提供一个更简洁的方法。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 启动服务
|
## 启动服务
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -67,8 +64,6 @@ sudo systemctl enable docker
|
|||||||
systemctl disable docker.service
|
systemctl disable docker.service
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 国内镜像
|
## 国内镜像
|
||||||
|
|
||||||
为了加速下载镜像文件,国内服务器可以指定国内的镜像!
|
为了加速下载镜像文件,国内服务器可以指定国内的镜像!
|
||||||
@ -85,14 +80,12 @@ Docker中国:https://registry.docker-cn.com
|
|||||||
|
|
||||||
腾讯云 https://mirror.ccs.tencentyun.com
|
腾讯云 https://mirror.ccs.tencentyun.com
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 写入配置文件 重启服务
|
### 写入配置文件 重启服务
|
||||||
|
|
||||||
```
|
```bash
|
||||||
sudo mkdir -p /etc/docker
|
sudo mkdir -p /etc/docker
|
||||||
|
|
||||||
#注意EOF前不能有空格
|
#注意EOF前不能有空格
|
||||||
sudo tee /etc/docker/daemon.json <<-'EOF'
|
sudo tee /etc/docker/daemon.json <<-'EOF'
|
||||||
{
|
{
|
||||||
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
|
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
|
||||||
@ -105,9 +98,8 @@ EOF
|
|||||||
sudo systemctl restart docker
|
sudo systemctl restart docker
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## docker 配置代理
|
## docker 配置代理
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo mkdir -p /etc/systemd/system/docker.service.d
|
sudo mkdir -p /etc/systemd/system/docker.service.d
|
||||||
sudo touch /etc/systemd/system/docker.service.d/proxy.conf
|
sudo touch /etc/systemd/system/docker.service.d/proxy.conf
|
||||||
@ -119,11 +111,14 @@ Environment="HTTP_PROXY=http://proxy.example.com:8080/"
|
|||||||
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
|
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
|
||||||
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
|
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
|
||||||
```
|
```
|
||||||
|
|
||||||
重启 服务
|
重启 服务
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl restart docker
|
sudo systemctl restart docker
|
||||||
```
|
```
|
||||||
|
|
||||||
## 迁移目录
|
## 迁移目录
|
||||||
|
|
||||||
主要是为了不让Docker镜像,容器占用系统盘的容量!
|
主要是为了不让Docker镜像,容器占用系统盘的容量!
|
||||||
@ -162,8 +157,6 @@ sudo systemctl restart docker
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 常用命令
|
## 常用命令
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -222,7 +215,62 @@ sudo systemctl restart docker
|
|||||||
docker inspect -f {{.Config.Hostname}} id
|
docker inspect -f {{.Config.Hostname}} id
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
|
||||||
|
#构建建启动nignx容器
|
||||||
|
docker-compose up -d nginx
|
||||||
|
|
||||||
|
#登录到nginx容器中
|
||||||
|
docker-compose exec nginx bash
|
||||||
|
|
||||||
|
#删除所有nginx容器,镜像
|
||||||
|
docker-compose down
|
||||||
|
|
||||||
|
#显示所有容器
|
||||||
|
docker-compose ps
|
||||||
|
|
||||||
|
#重新启动nginx容器
|
||||||
|
docker-compose restart nginx
|
||||||
|
|
||||||
|
#在php-fpm中不启动关联容器,并容器执行php -v 执行完成后删除容器
|
||||||
|
docker-compose run --no-deps --rm php-fpm php -v
|
||||||
|
|
||||||
|
#构建镜像 。
|
||||||
|
docker-compose build nginx
|
||||||
|
|
||||||
|
|
||||||
|
#不带缓存的构建。
|
||||||
|
docker-compose build --no-cache nginx
|
||||||
|
|
||||||
|
#查看nginx的日志
|
||||||
|
docker-compose logs nginx
|
||||||
|
|
||||||
|
# 查看nginx的实时日志
|
||||||
|
docker-compose logs -f nginx
|
||||||
|
|
||||||
|
#验证(docker-compose.yml)文件配置,当配置正确时,不输出任何内容,当文件配置错误,输出错误信息。
|
||||||
|
docker-compose config -q
|
||||||
|
|
||||||
|
#以json的形式输出nginx的docker日志
|
||||||
|
docker-compose events --json nginx
|
||||||
|
|
||||||
|
#暂停nignx容器
|
||||||
|
docker-compose pause nginx
|
||||||
|
|
||||||
|
#恢复ningx容器
|
||||||
|
docker-compose unpause nginx
|
||||||
|
|
||||||
|
#删除容器(删除前必须关闭容器)
|
||||||
|
docker-compose rm nginx
|
||||||
|
|
||||||
|
#停止nignx容器
|
||||||
|
docker-compose stop nginx
|
||||||
|
|
||||||
|
# 启动nignx容器
|
||||||
|
docker-compose start nginx
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 开发调试
|
## 开发调试
|
||||||
|
|
||||||
@ -242,7 +290,7 @@ sudo systemctl restart docker
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 容器目录映射
|
## 容器目录映射
|
||||||
|
|
||||||
以docker hub的centos:8为研究对象
|
以docker hub的centos:8为研究对象
|
||||||
|
|
||||||
@ -258,8 +306,6 @@ sudo systemctl restart docker
|
|||||||
|
|
||||||
宿主机映射目录会自动创建,容器映射目录中原来的文件都消失了,在一边操作等同于在另一边操作,且操作的是宿主机目录中的文件。
|
宿主机映射目录会自动创建,容器映射目录中原来的文件都消失了,在一边操作等同于在另一边操作,且操作的是宿主机目录中的文件。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**4、宿主机映射目录为空,容器映射目录不存在**
|
**4、宿主机映射目录为空,容器映射目录不存在**
|
||||||
|
|
||||||
容器映射目录会自动创建,且在一边操作等同于在另一边操作。
|
容器映射目录会自动创建,且在一边操作等同于在另一边操作。
|
||||||
@ -284,20 +330,12 @@ sudo systemctl restart docker
|
|||||||
|
|
||||||
容器映射目录中原来的文件都消失了。在一边操作等同于在另一边操作,且操作的是宿主机目录中的文件。
|
容器映射目录中原来的文件都消失了。在一边操作等同于在另一边操作,且操作的是宿主机目录中的文件。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
容器内没有网 不能解析dns
|
容器内没有网 不能解析dns
|
||||||
|
|
||||||
创建时添加以下参数
|
创建时添加以下参数
|
||||||
|
|
||||||
```
|
```
|
||||||
--network=host
|
--network=host
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,9 +2,44 @@
|
|||||||
|
|
||||||
|
|
||||||
#### 配置代理
|
#### 配置代理
|
||||||
|
http 协议代理
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git config --global http.proxy http://127.0.0.1:7890
|
//设置全局代理
|
||||||
git config --global https.proxy ttp://127.0.0.1:7890
|
//http
|
||||||
|
git config --global http.proxy http://127.0.0.1:1080
|
||||||
|
//https
|
||||||
|
git config --global https.proxy http://127.0.0.1:1080
|
||||||
|
//使用socks5代理的 例如ss,ssr 1080是windows下ss的默认代理端口,mac下不同,或者有自定义的,根据自己的改
|
||||||
|
git config --global http.proxy socks5://127.0.0.1:1080
|
||||||
|
git config --global https.proxy socks5://127.0.0.1:1080
|
||||||
|
|
||||||
|
//只对github.com使用代理,其他仓库不走代理
|
||||||
|
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
|
||||||
|
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
|
||||||
|
//取消github代理
|
||||||
|
git config --global --unset http.https://github.com.proxy
|
||||||
|
git config --global --unset https.https://github.com.proxy
|
||||||
|
|
||||||
|
//取消全局代理
|
||||||
|
git config --global --unset http.proxy
|
||||||
|
git config --global --unset https.proxy
|
||||||
|
```
|
||||||
|
|
||||||
|
ssh 协议代理
|
||||||
|
|
||||||
|
```bash
|
||||||
|
//对于使用git@协议的,可以配置socks5代理
|
||||||
|
//在~/.ssh/config 文件后面添加几行,没有可以新建一个
|
||||||
|
//socks5
|
||||||
|
Host github.com
|
||||||
|
User git
|
||||||
|
ProxyCommand connect -S 127.0.0.1:1080 %h %p
|
||||||
|
|
||||||
|
//http || https
|
||||||
|
Host github.com
|
||||||
|
User git
|
||||||
|
ProxyCommand connect -H 127.0.0.1:1080 %h %p
|
||||||
```
|
```
|
||||||
|
|
||||||
#### 更新git
|
#### 更新git
|
||||||
|
Loading…
x
Reference in New Issue
Block a user