zoukankan      html  css  js  c++  java
  • [Docker] Run Stateless Docker Containers (Volumes with docker compose)

    Docker containers should be designed to be stateless, meaning that they can survive system reboots and container terminations gracefully, and without the loss of data. Designing with stateless containers in mind will also help your app grow and make future horizontal scaling trivial.

    In this lesson, we will review an app that saves uploaded files to the filesystem. Then we will learn how to setup a persistent volume for the uploaded files so they can survive Docker container halts, restarts, stops and respawns.

    Dockerfile:

    FROM mhart/alpine-node
    WORKDIR /srv
    COPY . .
    RUN mkdir uploads
    RUN yarn
    EXPOSE 8080
    CMD node index.js

    docker-compose.yaml:

    version: '3'
    services:
      app:
        build: .
        ports:
          - "8080:8080"
        volumes:
          - appdata:/srv/uploads
    volumes:
      appdata:

    Remove docker compose:

    docker-compose rm -f
     
  • 相关阅读:
    Xargs
    录制终端会话-script--查找find
    命令之乐-cat
    Linux_shell编程--比较与测试
    线程进程
    计算机网络基础
    python基础-列表相关
    初学Python
    numpy 基本的数组统计方法
    python 操作mysql 入门
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14367490.html
Copyright © 2011-2022 走看看