简体   繁体   English

如何挂载AWS I3实例存储设备并从Docker中的C#应用​​程序使用

[英]How to mount AWS I3 instance storage devices and use from C# app in Docker

I want to use I3 fast drives from C# app that runs in Docker via ECS. 我想使用通过ECS在Docker中运行的C#应用​​程序中的I3快速驱动器。 But I do not see dev/nvme0n1 in the list of drives via System.IO.DriveInfo.GetDrives().Select(d => d.ToString()); 但是我没有通过System.IO.DriveInfo.GetDrives().Select(d => d.ToString());在驱动器列表中看到dev/nvme0n1 System.IO.DriveInfo.GetDrives().Select(d => d.ToString()); :

"/",
"/proc",
"/dev",
"/dev/pts",
"/sys",
"/sys/fs/cgroup",
"/sys/fs/cgroup/blkio",
"/sys/fs/cgroup/cpu",
"/sys/fs/cgroup/cpuacct",
"/sys/fs/cgroup/cpuset",
"/sys/fs/cgroup/devices", -- maybe here?
"/sys/fs/cgroup/freezer",
"/sys/fs/cgroup/hugetlb",
"/sys/fs/cgroup/memory",
"/sys/fs/cgroup/perf_event",
"/dev/mqueue",
"/etc/resolv.conf",
"/etc/hostname",
"/etc/hosts",
"/dev/shm",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger",
"/proc/kcore",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"

I have read that the devices are not formatted and not mounted at the start. 我已经阅读到设备没有格式化并且没有在一开始就安装。 How to format and mount them only once when the instance starts and not when I publish new docker images? 如何仅在实例启动时格式化和安装它们一次 ,而不在发布新的docker映像时格式化和装载它们? Or do so from code but check if already mounted and keep existing data? 还是从代码中这样做,但检查是否已挂载并保留现有数据?

Found a solution to store Docker volumes on instance storage. 找到了一种将Docker 存储在实例存储上的解决方案。

from this gist commands to replace /var/lib/docker/volumes with a link to dev/nvme0n1 : 这个gist命令中用dev/nvme0n1的链接替换/var/lib/docker/volumes dev/nvme0n1

#!/bin/sh -e
service docker stop || true
DEV="dev/nvme0n1"
umount $DEV 2>/dev/null || true
mkdir /mnt/docker-volumes 2>/dev/null || rm -rf /mnt/docker-volumes/*
mkfs.ext4 $DEV
rm -rf /var/lib/docker/vfs
rm -rf /var/lib/docker/volumes
mount -t ext4 -o noatime,data=writeback,nobh,barrier=0,commit=300 $DEV /mnt/docker-volumes
mkdir /mnt/docker-volumes/vfs
ln -s /mnt/docker-volumes/vfs /var/lib/docker/vfs
mkdir /mnt/docker-volumes/volumes
ln -s /mnt/docker-volumes/volumes /var/lib/docker/volumes

service docker start

Then a command VOLUME my-vol in Dockerfile creates/uses a volume in /mnt/docker-volumes/volumes directory on the host. 然后,Dockerfile中的命令VOLUME my-vol在主机上的/mnt/docker-volumes/volumes目录中创建/使用一个卷。

This commands must be run on host machine via SSH once, but then AWS ECS just works and I could publish new apps from Visual Studio with a couple of clicks. 该命令必须通过SSH在主机上运行一次,但是AWS ECS才可以运行,并且我只需单击几下就可以从Visual Studio发布新应用。 Haven't found a way to pass user data from ECS Create Cluster wizard, looks like it is not supported now. 尚未找到从ECS“创建群集”向导传递用户数据的方法,似乎现在不支持该方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM