简介
因为需要安装nexus,但是本地磁盘的空间是很小的,不能支撑nexus的数据,所以就准备把nexus的数据放在nas上,所以需要docker安装一个nfs volume插件,官网上看了一下发现netshare还可以,虽然有比较长一段时间没有更新了,但是使用应该没什么问题,我是在centos下安装的
操作
首先下载二进制文件
wget https://github.com/ContainX/docker-volume-netshare/releases/download/v0.36/docker-volume-netshare_0.36_linux_amd64-bin
然后配置systemed
编辑两个文件
vim /lib/systemd/system/docker-volume-netshare.service
[Unit]
Description=Docker NFS, AWS EFS & Samba/CIFS Volume Plugin
Documentation=https://github.com/gondor/docker-volume-netshare
Wants=network-online.target
After=network-online.target
Before=docker.service
[Service]
EnvironmentFile=/etc/sysconfig/docker-volume-netshare
ExecStart=/usr/bin/docker-volume-netshare $DKV_NETSHARE_OPTS -a 1.41 -v 3
StandardOutput=syslog
[Install]
WantedBy=multi-user.target
- -a 1.41 表示使用docker的1.41 api
- -v 3 表示使用nfs3协议
vim /etc/sysconfig/docker-volume-netshare
# Docker Volume Plugin - Netshare Upstart and SysVinit configuration file
# Customize location of the binary (especially for development testing).
#DKV_NETSHARE="/usr/bin/docker-volume-netshare"
#
# Customize the volume plugin startup options
#
## NFS
DKV_NETSHARE_OPTS="nfs"
## EFS
#DKV_NETSHARE_OPTS="efs --nameserver=169.254.169.253"
## CIFS
#DKV_NETSHARE_OPTS="cifs -u user -p pass -d domain"
之后启动docker-volume-netshare
systemctl daemon-reload
systemctl restart docker-volume-netshare
创建nexus的compose文件
version: "3"
services:
nexus:
image: "sonatype/nexus3:3.29.2"
container_name: "nexus"
restart: "always"
ports:
- "8082:8081"
- "8083:8083"
volumes:
- "nexus-data:/nexus-data"
- "nexus:/opt/sonatype/nexus"
volumes:
nexus-data:
driver: nfs
driver_opts:
share: 10.10.100.244:/nas/docker-volume/nexus/nexus-data
nexus:
driver: nfs
driver_opts:
share: 10.10.100.244:/nas/docker-volume/nexus/nexus
启动不报错一般就没有什么问题了
欢迎关注我的博客www.bboy.app
Have Fun