- 创建目录:/usr/local/docker/nexus/nexus-data(nexus-data数据卷目录)在nexus下编写docker-compose.yml,如下
version: '3' services: nexus: restart: always image: sonatype/nexus3 container_name: nexus3 ports: - 8081:8081 volumes: - /usr/local/docker/nexus/nexus-data:/nexus-data
-
运行docker-compose up即可
-
遇到的问题
cannot create directory '../sonatype-work/nexus3/log',Permission denied
发现是数据卷权限问题,
$ mkdir /some/dir/nexus-data && chown -R 200 /some/dir/nexus-data $ docker run -d -p 8081:8081 --name nexus -v /some/dir/nexus-data:/nexus-data sonatype/nexus3
上面是官方修改权限的命令原因SELinux,查看selinux配置文件
vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
如果SELINUX=enforcing 修改为disabled(也可以命令:sestatus 查看状态再修改),之后重启系统,运行步骤2
-
Centos7 SELinux操作链接: https://www.cnblogs.com/activiti/p/7552677.html 参考:https://blog.youkuaiyun.com/yoloyy/article/details/80205279