1. 查看docker仓库中的nginx命令

1
docker search nginx

2.为选定需要pull到系统重的官方Nginx镜像

1
docker pull nginx

这个过程需要时间,需要耐心等待一下。
看到这个图就是成功了。

3.列出已下载的镜像

1
docker images

4.列出运行中的容器

1
2
3
4
5
6
7
# 使用 docker ps -a 命令列出所有(包括已停止)的容器
docker ps -a
# 删除容器
docker rm <容器的唯一标示>

# 停止正在运行的容器
docker stop <容器名称>

5.启动跑个静态网页测试nginx容器

1
2
3
4
docker run --name nginxTest -d -p 8080:80 -v /usr/docker/nginx/html:/usr/share/nginx/html nginx

# 文件移动
mv <文件或者文件名路径> <目标目录>

6.注意docker的默认配置,如果docker的nginx没有默认配置,需要自行创建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 进入docker的默认配置
docker exec -it default-nginx bash

# 查看默认配置
cat /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;
}

# 可以看到docker指向的默认路径是/etc/nginx/,所以我们在etc/nginx创建这个路径和相应的文件就好了。
cat /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;

#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

# 退出容器
exit

服务器其他相关命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 查看服务器系统版本
lsb_release -a

# 停止nginx服务
pkill -9 nginx

# docker重启nginx
docker restart <镜像名称>

# 查看特定的进程
ps -ef|grep nginx
# 查看所有进程
ps -ef

# docker配置nginx静态资源路径,要修改docker,修改nginx没有用

参考文章

相关文章
评论
分享
  • 删除视频背景音乐、添加视频背景音乐

    删除视频背景音乐删除视频的背景音乐其实很简单,把视频数据导入进来,然后我们的视频数据其实是有两条轨道一条是音频,另外一条是视频。由于数据的tracks(轨道包含多条音视频)是只读的,所以在这里重新创建一个混合器,然后把数据源的视频轨道...

    删除视频背景音乐、添加视频背景音乐
  • AAC音频转WAV

    将aac编码格式的音频转为lpcm编码的音频,转出来的音频会比原来大个10倍左右.1234567891011121314151617181920212223242526272829303132333435363738394041424...

    AAC音频转WAV
  • Message Filtter Extension 短信过滤

    手机最近老是收到各种垃圾短信,于是想要自己写一个app来过滤垃圾短信,找到了Message Filtter Extension 1.首先创建一个空的工程,然后创建好了之后添加一个target。1选中工程->Editor-&g...

    Message Filtter Extension 短信过滤
  • Shell删除所有苹果证书

    123456789101112131415161718#!/bin/bashexpired=$(security find-identity)if [ -z "$expired" ] #-z判断字符串长度是否为0 为0返回tru...

    Shell删除所有苹果证书
  • Swift语言国际化

    第一步在工程设置里面添加对应国际化的语言 第二步添加Localizble.strings 第三步选择Localizble.strings文件,然后选择Localize…选择需要的语言,选择完了之后你就会看见刚才创建的Localizbl...

    Swift语言国际化
  • Nginx vue打包部署

    最近在弄vue的项目,完了需要打包部署到服务器,然后之前也没有弄过自己在这边一边查资料一边琢磨怎么弄。幸运的是花了一天半的时间还搞定了。 1.在conf.d文件下添加一个新的配置文件,12345678910111213141516...

    Nginx vue打包部署
  • SCP文件上传下载

    从服务器获取文件1scp -p 8080 root@192.168.1.1:/usr/temp/file.txt /Desktop/ 上传文件到服务器1scp -p 8080 /Desktop/uploadfile root@192....

    SCP文件上传下载
  • 音频剪切、合成、淡入淡出

    音频剪切1.音频剪切比较简单传入音频文件和剪切的时间段就可以了12345678910111213141516171819202122232425/** 初始化输出文件路径 */ NSString *url = "音频源文件路径"...

    音频剪切、合成、淡入淡出
  • swift 做一个答题的功能

    实现的效果是:1.点击答案,判断正确,如果选择的答案错误显示出正确的答案。然后可以浏览上一题的信息。2.可以查看上一题的答题情况。看下效果图吧 思路:1.看看题的模型吧,我这里是用一个数组来装的一个类,然后点击下一题的时候数组索引+...

    swift 做一个答题的功能
  • iOS原生调用ReatNative

    有一个RN的项目其中一个即时通讯的模块需要用原生来写所以这里面就涉及到iOS原生和RN的交互。 iOS调用RN1.创建一个交互通信的类。1234#import <React/RCTEventEmitter.h>#imp...

    iOS原生调用ReatNative