Skip to main content

Docker

alt Docker Pulls Count

Lati fa aworan docker tuntun to ti jẹ kikọ siwaju:

docker pull verdaccio/verdaccio

Docker pull

Tagged Versions#

Lati ẹya v2.x o le fa awọn aworan docker nipasẹ aami, bi iwọnyi:

Fun ẹya pataki kan:

docker pull verdaccio/verdaccio:4

Fun ẹya kekere kan:

docker pull verdaccio/verdaccio:4.0

Fun ẹya (awẹ) kan pato:

docker pull verdaccio/verdaccio:4.0.0

Ti o ba nifẹsi akojọ lori awọn aami, jọwọ lọ si aaye ayelujara ti Docker Hub.

Running Verdaccio using Docker#

Lati mu apoti docker ṣiṣẹ:

docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio

The last argument defines which image to use. The above line will pull the latest prebuilt image from dockerhub, if you haven't done that already.

Ti o ba ti kọ aworan kan ni ilana ibilẹ lo verdaccio gẹgẹbi ariyanjiyan ikẹhin.

O le lo -v lati de atopọ conf, storage ati plugins mọ eto faili ti olugbalejo naa:

V_PATH=/path/for/verdaccio; docker run -it --rm --name verdaccio \  -p 4873:4873 \  -v $V_PATH/conf:/verdaccio/conf \  -v $V_PATH/storage:/verdaccio/storage \  -v $V_PATH/plugins:/verdaccio/plugins \  verdaccio/verdaccio

Akiyesi: Verdaccio n ṣiṣẹ bi olumulo ti ko lo gbongbo (uid=10001) ninu apoti naa, if ti o ba lo atopọ dide lati fagbara bori atilẹwa, o nilo lati rii daju pe ọna atilẹyin naa jẹ pinpin si olumulo to tọ. In above example, you need to run sudo chown -R 10001:65533 /opt/verdaccio otherwise you will get permission errors at runtime. Lo iwọn iye docker o jẹ igbaniyanju lori lilo atopọ dide. Note: Verdaccio runs as a non-root user (uid=10001) inside the container, if you use bind mount to override default, you need to make sure the mount directory is assigned to the right user. In above example, you need to run sudo chown -R 10001:65533 /path/for/verdaccio otherwise you will get permission errors at runtime. Use docker volume is recommended over using bind mount.

Verdaccio 4 provides a new set of environment variables to modify either permissions, port or http protocol. Here the complete list:

Ohun iniatilẹwaApejuwe
VERDACCIO_APPDIR/opt/verdaccio-buildọna isisẹ ti docker naa
VERDACCIO_USER_NAMEverdaccioolumulo eto naa
VERDACCIO_USER_UID10001idanimọ olumulo naa ti o n jẹ lilo lati ṣamulo awọn igbanilaaye ti foda
VERDACCIO_PORT4873ibudo verdaccio naa
VERDACCIO_PROTOCOLhttpilana http atilẹwa naa

SELinux#

If SELinux is enforced in your system, the directories to be bind-mounted in the container need to be relabeled. Otherwise verdaccio will be forbidden from reading those files.

 fatal--- cannot open config file /verdaccio/conf/config.yaml: Error: CONFIG: it does not look like a valid config file

If verdaccio can't read files on a bind-mounted directory and you are unsure, please check /var/log/audit/audit.log to confirm that it's a SELinux issue. In this example, the error above produced the following AVC denial.

type=AVC msg=audit(1606833420.789:9331): avc:  denied  { read } for  pid=1251782 comm="node" name="config.yaml" dev="dm-2" ino=8178250 scontext=system_u:system_r:container_t:s0:c32,c258 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0

chcon can change the labels of shared files and directories. To make a directory accessible to containers, change the directory type to container_file_t.

$ chcon -Rt container_file_t ./conf

Dajudaju awọn nọmba ti o fi fun odiwọn -p nilo lati baramu.

An alternative solution is to use z and Z flags. To add the z flag to the mountpoint ./conf:/verdaccio/conf simply change it to ./conf:/verdaccio/conf:z. The z flag relabels the directory and makes it accessible by every container while the Z flags relables the directory and makes it accessible only to that specific container. However using these flags is dangerous. A small configuration mistake, like mounting /home/user or /var can mess up the labels on those directories and make the system unbootable.

Plugins#

O le ṣeto ibudo naa lati lo (fun awọn apoti ati agbalejo) nipasẹ fifi awọn aṣẹ ti o wa loke yii saaju pẹlu VERDACCIO_PORT=5000.

FROM verdaccio/verdaccio
USER root
ENV NODE_ENV=production
RUN npm i && npm install verdaccio-s3-storage
USER verdaccio

Docker and custom port configuration#

Docker ma pilẹṣẹ iye iwọn to ni orukọ inu eyi ti data ohun elo alatẹnumọ ma jẹ fifipamọ sii. O le lo docker inspect tabi docker volume inspect lati safihan ipo afojuri ti iye iwọn naa ati ṣatunkọ iṣeto naa, bii ti:

Iwe afọwọkọ npm kan naa tun wa fun kikọ aworan docker naa, nitorina o tun le ṣe:

V_PATH=/path/for/verdaccio; docker run -it --rm --name verdaccio \  -e "VERDACCIO_PORT=8080" -p 8080:8080 \    verdaccio/verdaccio

Of course the numbers you give to the -p parameter need to match.

Using HTTPS with Docker#

You can configure the protocol verdaccio is going to listen on, similarly to the port configuration. You have to overwrite the default value("http") of the PROTOCOL environment variable to "https", after you specified the certificates in the config.yaml.

docker run -it --rm --name verdaccio \  --env "VERDACCIO_PROTOCOL=https" -p 4873:4873  verdaccio/verdaccio

Using docker-compose#

  1. Gba ẹya tuntun ti docker-compose.
  2. Sagbedide ati ṣe imuṣiṣẹ apoti naa:
$ docker-compose up --build

Ibi ipamọ kan to dayatọ wa ti o n gbalejo ọpọlọpọ awọn iṣeto lati kọ awọn aworan Docker pẹlu verdaccio, fun apẹẹrẹ, bi aṣoju ikọkọ alayipada:

version: '3.1'
services:  verdaccio:    image: verdaccio/verdaccio    container_name: "verdaccio"    networks:      - node-network    environment:      - VERDACCIO_PORT=4873    ports:      - "4873:4873"    volumes:      - "./storage:/verdaccio/storage"      - "./config:/verdaccio/conf"      - "./plugins:/verdaccio/plugins"  networks:  node-network:    driver: bridge

Docker will generate a named volume in which to store persistent application data. You can use docker inspect or docker volume inspect to reveal the physical location of the volume and edit the configuration, such as:

$ docker volume inspect verdaccio_verdaccio[    {        "Name": "verdaccio_verdaccio",        "Driver": "local",        "Mountpoint": "/var/lib/docker/volumes/verdaccio_verdaccio/_data",        "Labels": null,        "Scope": "local"    }]

Build your own Docker image#

docker build -t verdaccio .

There is also an npm script for building the docker image, so you can also do:

yarn run build:docker

Note: The first build takes some minutes to build because it needs to run npm install, and it will take that long again whenever you change any file that is not listed in .dockerignore.

Please note that for any of the above docker commands you need to have docker installed on your machine and the docker executable should be available on your $PATH.

Docker Examples#

There is a separate repository that hosts multiple configurations to compose Docker images with verdaccio, for instance, as reverse proxy:

https://github.com/verdaccio/docker-examples

Docker Custom Builds#

If you have made an image based on Verdaccio, feel free to add it to this list.