Build a private NPM library with Verdaccio in Docker
Pull the mirror
- perform
docker pull verdaccio/verdaccio
Command to pull the latest Verdaccio image in docker
Obtaining configuration files
-
Run mkdir -p ~/docker/demo to create a docker folder in the root directory. The demo sub-folder is used to pull the Verdaccio project
-
Run CD ~/docker/demo to go to the demo folder.
Follow the git clone https://github.com/verdaccio/verdaccio orders, pull verdaccio project
- perform
cd verdaccio
Command to enter the project folder,
Git checkout -b 5.x origin/5.x
- perform
cd docker-examples
Go to the docker-examples folder
Run the mv docker-local-storage-volume ~/docker/verdaccio command to move the configuration files under the docker-local-storage-volume folder to the newly created verdaccio folder under the docker
- perform
chown -R 10001:65533 ~/docker/verdaccio
Set file permissions. Users in the Verdaccio container in docker environment are not current system users
Boot image
- perform
docker run --name verdaccio -itd -v ~/docker/verdaccio/conf:/verdaccio/conf -v ~/docker/verdaccio/storage:/verdaccio/storage -p 4873:4873 verdaccio/verdaccio
Command to start the image,
At this time through the docker ps – you can see a container has been started, access to the port 4873 can see warehouse is ready (my own dockerIP is http://192.168.99.100:4873/ for example below)
Publish a package
- Those with NRM can pass
NRM add Warehouse life Warehouse address
Add a source, such asNRM add verdaccio http://192.168.99.100:4873/
.
No NPM set registry http://192.168.99.100:4873/, is every switch to lose url too much trouble
-
Run NPM adduser, enter user name, password and email address as prompted to add a user, you can also go to the configuration file docker\verdaccio\conf\htpasswd to manually add the user
-
Run NPM login to login
-
Perform NPM publish under the package directory to publish
-
NPM unpublish package name –force
An error
- If you have
docker verdaccio one of the uplinks is down, refuse to publish
An error,
You need to modify the configuration file docker\verdaccio\conf\config.yaml and add it to the end of the file
## Special packages publish configurations
publish:
## This will allow the publisher to publish packages even if any uplink is down.
allow_offline: true
Copy the code