使用docker+verdaccio搭建npm私有库

参考文章,但是这个文章比较旧了,下载的项目已经迁移了,新的docker镜像拉取以后就不需要clone其他配置了。
1,在根目录创建docker文件夹,docker文件夹下创建verdaccio文件夹,在docker中执行以下代码拉取verdaccio的镜像;

docker pull verdaccio/verdaccio

2,运行镜像

docker run --name verdaccio -itd -v ~/docker/verdaccio:/verdaccio -p 4873:4873 verdaccio/verdaccio

 3,访问:  你的服务器ip:4873,能看到这个界面就成功了

4,以上配置好了以后,以后直接访问ip:4873就可以访问,但是某天突然不知道为啥连接不上了,于是我重新按照以上流程执行,但是第一步原本应该在verdaccio文件夹内自动生成以下配置文件,实际上并没有生成,于是决定删除所有与verdaccio相关的内容,然后重新配置

5,首先查看存在的容器:docker ps -a ,找到verdaccio并删除:docker rm  containerID

6,然后查看存在的docker镜像:docker images,找到verdaccio并删除:docker rmi  imageID

7,在根目录下创建文件夹docker,docker文件夹内创建verdaccio文件夹,执行授权命令:chown -R 10001:65533 ~/docker/verdaccio,verdaccio内放以下内容

8,其中conf中放以下内容:

9,docker-compose.yaml文件内容

version: '2.1'
services:
  verdaccio:
    image: verdaccio/verdaccio:4
    container_name: verdaccio-docker-local-storage-vol
    ports:
      - '4873:4873'
    volumes:
      - './storage:/verdaccio/storage'
      - './conf:/verdaccio/conf'
volumes:
  verdaccio:
    driver: local

10,config.yaml文件内容:

#
# This is the config file used for the docker images.
# It allows all users to do anything, so don't use it on production systems.
#
# Do not configure host and port under `listen` in this file
# as it will be ignored when using docker.
# see https://github.com/verdaccio/verdaccio/blob/master/wiki/docker.md#docker-and-custom-port-configuration
#
# Look here for more config file examples:
# https://github.com/verdaccio/verdaccio/tree/master/conf
#

# path to a directory with all packages
storage: /verdaccio/storage

auth:
  htpasswd:
    file: /verdaccio/conf/htpasswd
    # Maximum amount of users allowed to register, defaults to "+inf".
    # You can set this to -1 to disable registration.
    #max_users: 1000
security:
  api:
    jwt:
      sign:
        expiresIn: 60d
        notBefore: 1
  web:
    sign:
      expiresIn: 7d

# a list of other known repositories we can talk to
uplinks:
  npmjs:
    url: https://registry.npmjs.org/

packages:
  '@jota/*':
    access: $all
    publish: $all

  '@*/*':
    # scoped packages
    access: $all
    publish: $all
    proxy: npmjs

  '**':
    # allow all users (including non-authenticated users) to read and
    # publish all packages
    #
    # you can specify usernames/groupnames (depending on your auth plugin)
    # and three keywords: "$all", "$anonymous", "$authenticated"
    access: $all

    # allow all known users to publish packages
    # (anyone can register by default, remember?)
    publish: $all

    # if package is not available locally, proxy requests to 'npmjs' registry
    proxy: npmjs

# To use `npm audit` uncomment the following section
middlewares:
  audit:
    enabled: true

# log settings
logs:
  - { type: stdout, format: pretty, level: trace }
  #- {type: file, path: verdaccio.log, level: info}

11,htpasswd文件内容:

jpicado:$6vkdNgRX2npc:autocreated 2017-07-11T18:48:38.003Z

12,最后执行命令,启动镜像

docker run --name verdaccio -itd -v ~/docker/verdaccio:/verdaccio -p 4873:4873 verdaccio/verdaccio

13,再次打开ip:4873又正常运行了,只不过之前存在的所有的包都不见了,因为我删除了容器和镜像

14,今天又又又退出了,docker ps -a查看存在的容器,发现verdaccio容器是存在的,但是18分钟前exited退出了,退出码是137

目前不清楚具体原因,可能是容器中运行的代码出错了,突然就exited了,但是不要紧,我们重启这个容器就OK了: docker  restart  容器ID

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值