11---
22date : 2021-08-25
33---
4+
45# Docker
56
67## 安装
@@ -17,7 +18,6 @@ brew install --cask --appdir=/Applications docker
1718
1819[ Install Docker Desktop on Mac] ( https://docs.docker.com/desktop/mac/install/ )
1920
20-
2121### 镜像加速
2222
2323打开docker的设置,修改Docker Engine中registry-mirrors地址
@@ -48,11 +48,8 @@ brew install --cask --appdir=/Applications docker
4848
4949- 科大镜像 [ https://docker.mirrors.ustc.edu.cn/ ] ( https://docker.mirrors.ustc.edu.cn/ )
5050
51-
52-
5351## 命令
5452
55-
5653### docker ps
5754
5855[ docker ps] ( https://docs.docker.com/engine/reference/commandline/ps/ )
@@ -61,7 +58,6 @@ brew install --cask --appdir=/Applications docker
6158
6259docker ps --filter ancestor=hello-world -a
6360
64-
6561### docker container
6662
6763[ docker container] ( https://docs.docker.com/engine/reference/commandline/container/ )
@@ -72,16 +68,18 @@ docker ps --filter ancestor=hello-world -a
7268
7369docker container rm $(docker ps --filter ancestor=hello-world -qa)
7470
75-
7671### docker exec
7772
7873[ docker exec] ( https://docs.docker.com/engine/reference/commandline/exec/ )
7974
8075以交互方式进入容器
8176
82- docker exec -it containerId command
77+ docker exec -it containerId command
8378
84- command与镜像构建有关,可以查看镜像的构建描述。比如[ redis: alpine3 .14] ( https://hub.docker.com/layers/redis/library/redis/alpine3.14/images/sha256-6edcbc387edd866a080491c015c029b458f49678152dfe364ad50383620c3215?context=explore ) 这个镜像就是基于` /bin/sh ` ,那么就不能像进入[ ubuntu] ( https://hub.docker.com/layers/ubuntu/library/ubuntu/latest/images/sha256-0f745a413c7886d6dc4f1e6a1d45a5cf5a9a85f72e6243b307e17d67e2e1fe10?context=explore ) 容器那样使用` /bin/bash `
79+ command与镜像构建有关,可以查看镜像的构建描述。比如[ redis: alpine3 .14] ( https://hub.docker.com/layers/redis/library/redis/alpine3.14/images/sha256-6edcbc387edd866a080491c015c029b458f49678152dfe364ad50383620c3215?context=explore )
80+ 这个镜像就是基于` /bin/sh `
81+ ,那么就不能像进入[ ubuntu] ( https://hub.docker.com/layers/ubuntu/library/ubuntu/latest/images/sha256-0f745a413c7886d6dc4f1e6a1d45a5cf5a9a85f72e6243b307e17d67e2e1fe10?context=explore )
82+ 容器那样使用` /bin/bash `
8583
8684### 日志
8785
@@ -95,18 +93,17 @@ docker logs -f --tail 100 66c017d8fc53
9593
9694docker commit some-rabbit some-rabbit_new
9795
98-
9996## 磁盘清理
10097
101- > 参考:[ https://betterprogramming.pub/docker-tips-clean-up-your-local-machine-35f370a01a78 ] ( https://betterprogramming.pub/docker-tips-clean-up-your-local-machine-35f370a01a78 )
98+ >
99+ 参考:[ https://betterprogramming.pub/docker-tips-clean-up-your-local-machine-35f370a01a78 ] ( https://betterprogramming.pub/docker-tips-clean-up-your-local-machine-35f370a01a78 )
102100
103101``` shell
104102docker system df
105103```
106104
107105![ 执行结果] ( images/img_2.png )
108106
109-
110107- Images:所有镜像占用的空间。
111108- Containers:运行的容器占用的空间,表示每个容器的读写层的空间。
112109- Local Volumes:容器挂载本地数据卷的空间。
@@ -122,4 +119,56 @@ docker builder prune
122119
123120``` shell
124121docker system prune
125- ```
122+ ```
123+
124+ ## 安装Nginx
125+
126+ - 创建好要挂载的目录mydata
127+
128+ ``` shell
129+ mkdir -p < mydata> /nginx/nginx.conf
130+ mkdir -p < mydata> /nginx/html
131+ mkdir -p < mydata> /nginx/log
132+ ````
133+
134+ ` ` ` text
135+ // nginx.conf
136+ worker_processes 1;
137+
138+ events {
139+ worker_connections 1024;
140+ }
141+
142+ http {
143+ include mime.types;
144+ default_type application/octet-stream;
145+ sendfile on;
146+ keepalive_timeout 65;
147+
148+ server {
149+ listen 80;
150+ server_name localhost;
151+
152+ location / {
153+ root /home/ruoyi/projects/ruoyi-ui;
154+ try_files $uri $uri / /index.html;
155+ index index.html index.htm;
156+ }
157+
158+ error_page 500 502 503 504 /50x.html;
159+ location = /50x.html {
160+ root html;
161+ }
162+ }
163+ }
164+ ` ` `
165+
166+ mydata/nginx/html内创建一个默认的index.html
167+
168+
169+ - 运行
170+
171+ ` ` ` shell
172+ docker run -d -p 80:80 --name nginx --privileged=true -v < mydata> /nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v < mydata> /nginx/html:/etc/nginx/html -v < mydata> /nginx/log:/var/log/nginx 镜像ID/名称
173+ ` ` `
174+
0 commit comments