参考文章,但是这个文章比较旧了,下载的项目已经迁移了,新的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