2017-12-16 13:25:59 +01:00
---
id: docker
title: Docker
---
2017-06-24 11:59:25 +02:00
2018-05-01 09:21:43 +02:00
< div class = "docker-count" >
![alt Docker Pulls Count ](http://dockeri.co/image/verdaccio/verdaccio "Docker Pulls Count" )
< / div >
2017-06-24 11:59:25 +02:00
To pull the latest pre-built [docker image ](https://hub.docker.com/r/verdaccio/verdaccio/ ):
2018-01-20 23:00:45 +01:00
```bash
docker pull verdaccio/verdaccio
```
2017-06-24 11:59:25 +02:00
2018-05-08 21:08:56 +02:00
![Docker pull ](/svg/docker_verdaccio.gif )
2018-05-05 11:02:17 +02:00
2017-06-24 11:59:25 +02:00
## Tagged Versions
Since version `v2.x` you can pull docker images by [tag ](https://hub.docker.com/r/verdaccio/verdaccio/tags/ ), as follows:
For a major version:
```bash
2018-05-31 10:32:46 +02:00
docker pull verdaccio/verdaccio:3
2017-06-24 11:59:25 +02:00
```
For a minor version:
```bash
2018-05-31 10:32:46 +02:00
docker pull verdaccio/verdaccio:3.0
2017-06-24 11:59:25 +02:00
```
For a specific (patch) version:
```bash
2018-05-31 10:32:46 +02:00
docker pull verdaccio/verdaccio:3.0.1
2017-06-24 11:59:25 +02:00
```
2017-10-08 09:13:54 +02:00
2018-05-31 11:11:35 +02:00
For the next major release using the `beta` (master branch) version.
2017-10-06 07:21:05 +02:00
```bash
2018-04-18 08:20:57 +02:00
docker pull verdaccio/verdaccio:beta
2017-10-06 07:21:05 +02:00
```
2018-01-20 23:00:45 +01:00
> If you are interested on a list of tags, [please visit the Docker Hub website](https://hub.docker.com/r/verdaccio/verdaccio/tags/).
2018-01-09 18:00:47 +01:00
## Running verdaccio using Docker
2017-06-24 11:59:25 +02:00
To run the docker container:
```bash
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
```
2017-12-16 13:25:59 +01:00
The last argument defines which image to use.
2017-06-24 11:59:25 +02:00
The above line will pull the latest prebuilt image from dockerhub, if you haven't done that already.
If you have [build an image locally ](#build-your-own-docker-image ) use `verdaccio` as the last argument.
2018-03-24 13:29:51 +01:00
You can use `-v` to bind mount `conf` and `storage` to the hosts filesystem:
2017-06-24 11:59:25 +02:00
```bash
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 \
verdaccio/verdaccio
```
2018-05-03 20:44:42 +02:00
>Note: Verdaccio runs as a non-root user (uid=100, gid=101) 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 100:101 /opt/verdaccio` otherwise you will get permission errors at runtime. [Use docker volume ](https://docs.docker.com/storage/volumes/ ) is recommended over using bind mount.
2017-06-24 11:59:25 +02:00
2018-01-09 18:00:47 +01:00
### Docker and custom port configuration
2017-06-24 11:59:25 +02:00
Any `host:port` configured in `conf/config.yaml` under `listen` is currently ignored when using docker.
If you want to reach verdaccio docker instance under different port, lets say `5000`
in your `docker run` command replace `-p 4873:4873` with `-p 5000:4873` .
In case you need to specify which port to listen to **in the docker container** ,
since version 2.?.? you can do so by providing additional arguments to `docker run` : `--env PORT=5000`
This changes which port the docker container exposes and the port verdaccio listens to.
Of course the numbers you give to `-p` paremeter need to match,
so assuming you want them to all be the same this is what you could copy, paste and adopt:
```bash
2017-12-16 13:25:59 +01:00
PORT=5000; docker run -it --rm --name verdaccio \
2017-06-24 11:59:25 +02:00
--env PORT -p $PORT:$PORT
verdaccio/verdaccio
```
2018-01-09 18:00:47 +01:00
### Using HTTPS with Docker
2017-07-05 09:47:29 +02:00
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.
```bash
2017-12-16 13:25:59 +01:00
PROTOCOL=https; docker run -it --rm --name verdaccio \
2017-07-05 09:47:29 +02:00
--env PROTOCOL -p 4873:4873
verdaccio/verdaccio
```
2018-01-09 18:00:47 +01:00
### Using docker-compose
2017-06-24 11:59:25 +02:00
1. Get the latest version of [docker-compose ](https://github.com/docker/compose ).
2017-12-16 13:25:59 +01:00
2. Build and run the container:
2017-06-24 11:59:25 +02:00
```bash
$ docker-compose up --build
```
2017-09-10 13:55:14 +02:00
You can set the port to use (for both container and host) by prefixing the above command with `PORT=5000 ` .
2017-06-24 11:59:25 +02:00
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:
2017-12-16 13:25:59 +01:00
2017-06-24 11:59:25 +02:00
```
$ docker volume inspect verdaccio_verdaccio
[
{
"Name": "verdaccio_verdaccio",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/verdaccio_verdaccio/_data",
"Labels": null,
"Scope": "local"
}
]
```
2018-01-09 18:00:47 +01:00
## Build your own Docker image
2017-06-24 11:59:25 +02:00
```bash
docker build -t verdaccio .
```
There is also an npm script for building the docker image, so you can also do:
```bash
2017-07-22 18:21:49 +02:00
npm run build:docker
2017-06-24 11:59:25 +02:00
```
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` .
If you want to use the docker image on a rpi or a compatible device there is also a dockerfile available.
To build the docker image for raspberry pi execute:
```bash
2017-07-22 18:21:49 +02:00
npm run build:docker:rpi
2017-06-24 11:59:25 +02:00
```
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` .
2018-01-09 18:00:47 +01:00
## Docker Examples
2017-06-24 11:59:25 +02:00
There is a separate repository that hosts multiple configurations to compose Docker images with `verdaccio` , for instance, as reverse proxy:
2018-04-18 08:20:57 +02:00
[https://github.com/verdaccio/docker-examples ](https://github.com/verdaccio/docker-examples )
2018-01-21 10:10:10 +01:00
## Docker Custom Builds
* [docker-verdaccio-gitlab ](https://github.com/snics/docker-verdaccio-gitlab )
* [docker-verdaccio ](https://github.com/deployable/docker-verdaccio )
* [docker-verdaccio-s3 ](https://github.com/asynchrony/docker-verdaccio-s3 ) Private NPM container that can backup to s3
* [docker-verdaccio-ldap ](https://github.com/snadn/docker-verdaccio-ldap )
* [verdaccio-ldap ](https://github.com/nathantreid/verdaccio-ldap )
* [verdaccio-compose-local-bridge ](https://github.com/shingtoli/verdaccio-compose-local-bridge )
* [docker-verdaccio ](https://github.com/Global-Solutions/docker-verdaccio )
* [verdaccio-docker ](https://github.com/idahobean/verdaccio-docker )
* [verdaccio-server ](https://github.com/andru255/verdaccio-server )
* [coldrye-debian-verdaccio ](https://github.com/coldrye-docker/coldrye-debian-verdaccio ) docker image providing verdaccio from coldrye-debian-nodejs.