[Docker] Run Stateless Docker Containers (Volumes with docker compose)
Docker with run Compose Containers
2023-09-14 08:59:13 时间
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
相关文章
- docker探索-Docker 1.13 编排能力进化(十三)
- 【Docker】iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8480 -j DNAT --to-destination 172.17.0.2:80 ! -i docker0: iptables: No chain/target/match by that name
- 【Docker】docker的安装和常用命令
- Docker 安装和基础用法
- Docker - docker in docker(dind)
- [Docker] Container & image (docker run)
- docker如何创建一个运行后台进程的容器并同时提供shell终端
- 运维基础之Docker(7)关于docker latest tag
- Play with docker 1.12
- Docker - 访问容器
- [DevOps] Set up and run a PostgreSQL instance locally with Docker Compose
- docker 每次都得source /etc/profile以及如何查看Docker容器环境变量、向容器传递环境变量
- 使用阿里云容器服务Jenkins实现持续集成和Docker镜像构建(updated on 2017.3.3)
- Docker容器mysql创建表报错:Table ‘mybatis_plus.USER‘ doesn‘t exist 问题解决
- 【Docker】在本地打包maven程序为docker镜像报错: Connect to localhost:2375 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1]
- 81.第十七章 企业级容器技术docker -- Docker 数据管理、Docker网络管理(九)
- 【问题解决】The “docker“ driver should not be used with root privileges
- 【云原生之Docker实战】使用docker部署mkdocs项目文档工具
- 【云原生之Docker实战】使用docker部署webterminal堡垒机
- 【云原生之Docker实战】安装docker镜像分析工具Dive
- docker velocyto.r
- Ubuntu18.04关闭docker开机自启动(六十四)
- Docker----安装 docker-compose 环境
- 19 - vulhub - docker daemon api 未授权访问漏洞
- RTX30系列linux+docker容器的GPU配置(tensorflow-gpu==1.15~2.x、tensorrt 7、cuda、cudnn)附加resnet50模型测试