Docker相关

  • 将docker装入指定文件夹

    修改配置文件

    1
    2
    3
    4
    5
    6
    vim /etc/docker/daemon.json

    {
    "registry-mirrors": ["http://hub-mirror.c.163.com"],
    "graph":"/opt/docker" //指定文件夹
    }

    然后安装即可

    使用普通用户权限执行docker

    1
    2
    3
    4
    5
    6
    7
    #创建docker组
    sudo groupadd docker
    #添加ithing进入docker组
    sudo gpasswd -a user docker
    #重启docker服务
    sudo systemctl restart docker
    #接下来就可以使用你添加的用户(user)使用docker命令了

    在启动docker后生成的docker目录属于root,普通用户无法访问。

    直接修改文件权限

    1
    sudo chown user:user docker

    安装Portainer

    1
    2
    docker pull portainer/portainer-ce
    docker run -d --name portainer -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart always portainer/portainer-ce

    docker-compose

    1
    2
    3
    sudo apk add docker-compose
    #在有docker-compose.yml的目录下执行以下指令
    sudo docker-compose up -d

    docker-compose.yml小例子

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    version: '3.3'
    services:
    dashdot:
    restart: unless-stopped
    privileged: false
    container_name: dashdot
    ports:
    - '1001:3001'
    volumes:
    - '/:/mnt/host:ro'
    environment:
    - DASHDOT_ENABLE_CPU_TEMPS=true
    - DASHDOT_ENABLE_STORAGE_SPLIT_VIEW=true
    - DASHDOT_ALWAYS_SHOW_PERCENTAGES=true
    - DASHDOT_PAGE_TITLE=Redmi2 No.1
    image: 'mauricenino/dashdot:latest'

    安装nginx

    1
    2
    3
    4
    5
    6
    7
    #先随便启动一个nginx
    docker run -d --name nginx nginx
    #启动容器后,其内部会生成一个nginx的配置文件,将其复制到本地对应文件夹中
    docker cp nginx:/etc/nginx/nginx.conf $PWD/
    #然后就可以删除这个容器了
    docker container stop nginx
    docker container rm nginx

    部署容器

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    version: '3'
    services:
    nginx:
    restart: always
    container_name: nginx
    image: nginx
    ports:
    - 1008:80
    - 1443:443
    volumes:
    - /home/user/Disk/nginx/www/public:/usr/share/nginx/html
    - /home/user/Disk/nginx/logs:/var/log/nginx
    - /home/user/Disk/nginx/conf:/etc/nginx/conf.d/
    environment:
    - NGINX_PORT=80
    privileged: true
    1
    docker-compose up -d#启动容器

    public中需要存在index.html文件否则会出现403错误:

    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
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    <html>
    <head>
    <meta charset="utf-8">
    <title>loveHeart</title>
    <link rel="shortcut icon" href="http://zhouql.vip/images/心.png" type="image/x-icon">
    <style>
    html,
    body {
    height: 100%;
    padding: 0;
    margin: 0;
    background: #000;
    }
    canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    }
    </style>
    </head>
    <body>
    <canvas id="pinkboard"></canvas>
    <script>
    var settings = {
    particles: {
    length: 500,
    duration: 2,
    velocity: 100,
    effect: -0.75,
    size: 32,
    },
    };
    (function () { var b = 0; var c = ["ms", "moz", "webkit", "o"]; for (var a = 0; a < c.length && !window.requestAnimationFrame; ++a) { window.requestAnimationFrame = window[c[a] + "RequestAnimationFrame"]; window.cancelAnimationFrame = window[c[a] + "CancelAnimationFrame"] || window[c[a] + "CancelRequestAnimationFrame"] } if (!window.requestAnimationFrame) { window.requestAnimationFrame = function (h, e) { var d = new Date().getTime(); var f = Math.max(0, 16 - (d - b)); var g = window.setTimeout(function () { h(d + f) }, f); b = d + f; return g } } if (!window.cancelAnimationFrame) { window.cancelAnimationFrame = function (d) { clearTimeout(d) } } }());

    var Point = (function () {
    function Point(x, y) {
    this.x = (typeof x !== 'undefined') ? x : 0;
    this.y = (typeof y !== 'undefined') ? y : 0;
    }
    Point.prototype.clone = function () {
    return new Point(this.x, this.y);
    };
    Point.prototype.length = function (length) {
    if (typeof length == 'undefined')
    return Math.sqrt(this.x * this.x + this.y * this.y);
    this.normalize();
    this.x *= length;
    this.y *= length;
    return this;
    };
    Point.prototype.normalize = function () {
    var length = this.length();
    this.x /= length;
    this.y /= length;
    return this;
    };
    return Point;
    })();
    var Particle = (function () {
    function Particle() {
    this.position = new Point();
    this.velocity = new Point();
    this.acceleration = new Point();
    this.age = 0;
    }
    Particle.prototype.initialize = function (x, y, dx, dy) {
    this.position.x = x;
    this.position.y = y;
    this.velocity.x = dx;
    this.velocity.y = dy;
    this.acceleration.x = dx * settings.particles.effect;
    this.acceleration.y = dy * settings.particles.effect;
    this.age = 0;
    };
    Particle.prototype.update = function (deltaTime) {
    this.position.x += this.velocity.x * deltaTime;
    this.position.y += this.velocity.y * deltaTime;
    this.velocity.x += this.acceleration.x * deltaTime;
    this.velocity.y += this.acceleration.y * deltaTime;
    this.age += deltaTime;
    };
    Particle.prototype.draw = function (context, image) {
    function ease(t) {
    return (--t) * t * t + 1;
    }
    var size = image.width * ease(this.age / settings.particles.duration);
    context.globalAlpha = 1 - this.age / settings.particles.duration;
    context.drawImage(image, this.position.x - size / 2, this.position.y - size / 2, size, size);
    };
    return Particle;
    })();
    var ParticlePool = (function () {
    var particles,
    firstActive = 0,
    firstFree = 0,
    duration = settings.particles.duration;
    function ParticlePool(length) {
    // create and populate particle pool
    particles = new Array(length);
    for (var i = 0; i < particles.length; i++)
    particles[i] = new Particle();
    }
    ParticlePool.prototype.add = function (x, y, dx, dy) {
    particles[firstFree].initialize(x, y, dx, dy);
    // handle circular queue
    firstFree++;
    if (firstFree == particles.length) firstFree = 0;
    if (firstActive == firstFree) firstActive++;
    if (firstActive == particles.length) firstActive = 0;
    };
    ParticlePool.prototype.update = function (deltaTime) {
    var i;
    // update active particles
    if (firstActive < firstFree) {
    for (i = firstActive; i < firstFree; i++)
    particles[i].update(deltaTime);
    }
    if (firstFree < firstActive) {
    for (i = firstActive; i < particles.length; i++)
    particles[i].update(deltaTime);
    for (i = 0; i < firstFree; i++)
    particles[i].update(deltaTime);
    }
    // remove inactive particles
    while (particles[firstActive].age >= duration && firstActive != firstFree) {
    firstActive++;
    if (firstActive == particles.length) firstActive = 0;
    }
    };
    ParticlePool.prototype.draw = function (context, image) {
    // draw active particles
    if (firstActive < firstFree) {
    for (i = firstActive; i < firstFree; i++)
    particles[i].draw(context, image);
    }
    if (firstFree < firstActive) {
    for (i = firstActive; i < particles.length; i++)
    particles[i].draw(context, image);
    for (i = 0; i < firstFree; i++)
    particles[i].draw(context, image);
    }
    };
    return ParticlePool;
    })();
    (function (canvas) {
    var context = canvas.getContext('2d'),
    particles = new ParticlePool(settings.particles.length),
    particleRate = settings.particles.length / settings.particles.duration, // particles/sec
    time;
    // get point on heart with -PI <= t <= PI
    function pointOnHeart(t) {
    return new Point(
    160 * Math.pow(Math.sin(t), 3),
    130 * Math.cos(t) - 50 * Math.cos(2 * t) - 20 * Math.cos(3 * t) - 10 * Math.cos(4 * t) + 25
    );
    }
    // creating the particle image using a dummy canvas
    var image = (function () {
    var canvas = document.createElement('canvas'),
    context = canvas.getContext('2d');
    canvas.width = settings.particles.size;
    canvas.height = settings.particles.size;
    // helper function to create the path
    function to(t) {
    var point = pointOnHeart(t);
    point.x = settings.particles.size / 2 + point.x * settings.particles.size / 350;
    point.y = settings.particles.size / 2 - point.y * settings.particles.size / 350;
    return point;
    }
    // create the path
    context.beginPath();
    var t = -Math.PI;
    var point = to(t);
    context.moveTo(point.x, point.y);
    while (t < Math.PI) {
    t += 0.01; // baby steps!
    point = to(t);
    context.lineTo(point.x, point.y);
    }
    context.closePath();
    // create the fill
    context.fillStyle = '#ea80b0';
    context.fill();
    // create the image
    var image = new Image();
    image.src = canvas.toDataURL();
    return image;
    })();
    // render that thing!
    function render() {
    // next animation frame
    requestAnimationFrame(render);
    // update time
    var newTime = new Date().getTime() / 1000,
    deltaTime = newTime - (time || newTime);
    time = newTime;
    // clear canvas
    context.clearRect(0, 0, canvas.width, canvas.height);
    // create new particles
    var amount = particleRate * deltaTime;
    for (var i = 0; i < amount; i++) {
    var pos = pointOnHeart(Math.PI - 2 * Math.PI * Math.random());
    var dir = pos.clone().length(settings.particles.velocity);
    particles.add(canvas.width / 2 + pos.x, canvas.height / 2 - pos.y, dir.x, -dir.y);
    }
    // update and draw particles
    particles.update(deltaTime);
    particles.draw(context, image);
    }
    // handle (re-)sizing of the canvas
    function onResize() {
    canvas.width = canvas.clientWidth;
    canvas.height = canvas.clientHeight;
    }
    window.onresize = onResize;
    // delay rendering bootstrap
    setTimeout(function () {
    onResize();
    render();
    }, 10);
    })(document.getElementById('pinkboard'));
    </script>
    </body>

    </html>

    conf中使用默认nginx.conf:

    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
    server {
    listen 80;
    listen [::]:80;
    server_name localhost;

    #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;
    #}
    }

    nginx 反向代理hexo

    1. 安装git【设置ssh公钥免密登陆可按照百度来,easy】

      1
      sudo apk add git
    2. 创建远程git仓库

      1
      git init --bare blog.git
    3. 配置hooks文件

      在blog.git下的hooks目录下创建post-receive文件,内容为:

      1
      2
      #!/bin/bash
      git --work-tree=【待上传blog仓库目录】 --git-dir=【自己的目录】/blog.git checkout -f
    4. 在本地hexo配置文件中添加deploy路径

      1
      2
      3
      4
      deploy:
      type: git
      repo:
      [nickname]: [username]@[yourRemoteIP]:[yourDir]/mygit/blog.git
    5. 访问[yourIP]:1008,即可看见自己的blog

    作者: Meow Mii

    本文链接: https://blog.yiochin.top/p/316feddf.html

    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0 许可协议,转载请注明出处!


    📝 Comment