0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-20 22:52:46 -05:00
verdaccio/website/translated_docs/zh-Hans/docker.md
verdacciobot 81f367f4b2 New Crowdin translations (#871)
* New translations uplinks.md (Chinese Simplified)
docs(website): new translations

* New translations uplinks.md (Chinese Simplified)
docs(website): new translations

* New translations what-is-verdaccio.md (Chinese Simplified)
docs(website): new translations

* New translations config.md (Chinese Simplified)
docs(website): new translations

* New translations plugins.md (Chinese Simplified)
docs(website): new translations

* New translations config.md (Chinese Simplified)
docs(website): new translations

* New translations what-is-verdaccio.md (Chinese Simplified)
docs(website): new translations

* New translations windows.md (Chinese Simplified)
docs(website): new translations

* New translations dev-plugins.md (Chinese Simplified)
docs(website): new translations

* New translations dev-plugins.md (Chinese Simplified)
docs(website): new translations

* New translations dev-plugins.md (Chinese Simplified)
docs(website): new translations

* New translations dev-plugins.md (Chinese Simplified)
docs(website): new translations

* New translations dev-plugins.md (Chinese Simplified)
docs(website): new translations

* New translations docker.md (Chinese Simplified)
docs(website): new translations

* New translations docker.md (Chinese Simplified)
docs(website): new translations

* New translations docker.md (Chinese Simplified)
docs(website): new translations

* New translations docker.md (Chinese Simplified)
docs(website): new translations

* New translations docker.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Spanish)
docs(website): new translations

* New translations contributing.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Portuguese, Brazilian)
docs(website): new translations

* New translations config.md (Spanish)
docs(website): new translations

* New translations web.md (Portuguese, Brazilian)
docs(website): new translations

* New translations web.md (Spanish)
docs(website): new translations

* New translations config.md (Chinese Simplified)
docs(website): new translations

* New translations config.md (Portuguese, Brazilian)
docs(website): new translations

* New translations web.md (Chinese Simplified)
docs(website): new translations

* New translations install.md (Chinese Simplified)
docs(website): new translations

* New translations node-api.md (Chinese Simplified)
docs(website): new translations

* New translations contributing.md (Chinese Simplified)
docs(website): new translations

* New translations web.md (Chinese Simplified)
docs(website): new translations

* New translations packages.md (Chinese Simplified)
docs(website): new translations

* New translations plugins.md (Spanish)
docs(website): new translations

* New translations plugins.md (Portuguese, Brazilian)
docs(website): new translations

* New translations plugins.md (Chinese Simplified)
docs(website): new translations

* New translations ansible.md (Polish)
docs(website): new translations

* New translations repositories.md (Polish)
docs(website): new translations

* New translations chef.md (Polish)
docs(website): new translations

* New translations puppet.md (Polish)
docs(website): new translations

* New translations ci.md (Polish)
docs(website): new translations

* New translations what-is-verdaccio.md (Polish)
docs(website): new translations

* New translations node-api.md (Polish)
docs(website): new translations

* New translations windows.md (Polish)
docs(website): new translations

* New translations web.md (Polish)
docs(website): new translations

* New translations use-cases.md (Polish)
docs(website): new translations

* New translations uplinks.md (Polish)
docs(website): new translations

* New translations test.md (Polish)
docs(website): new translations

* New translations ssl.md (Polish)
docs(website): new translations

* New translations server.md (Polish)
docs(website): new translations

* New translations reverse-proxy.md (Polish)
docs(website): new translations

* New translations protect-your-dependencies.md (Polish)
docs(website): new translations

* New translations auth.md (Polish)
docs(website): new translations

* New translations plugins.md (Polish)
docs(website): new translations

* New translations packages.md (Polish)
docs(website): new translations

* New translations notifications.md (Polish)
docs(website): new translations

* New translations logger.md (Polish)
docs(website): new translations

* New translations kubernetes.md (Polish)
docs(website): new translations

* New translations install.md (Polish)
docs(website): new translations

* New translations iis-server.md (Polish)
docs(website): new translations

* New translations docker.md (Polish)
docs(website): new translations

* New translations dev-plugins.md (Polish)
docs(website): new translations

* New translations contributing.md (Polish)
docs(website): new translations

* New translations config.md (Polish)
docs(website): new translations

* New translations cli.md (Polish)
docs(website): new translations

* New translations build.md (Polish)
docs(website): new translations

* New translations en.json (Polish)
docs(website): new translations
2018-08-01 22:25:11 +02:00

166 lines
No EOL
6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: docker
title: Docker
---
<div class="docker-count">
![alt Docker Pulls Count](http://dockeri.co/image/verdaccio/verdaccio "Docker Pulls Count")
</div>
要下载(pull)最新的预先-创建的[docker镜像](https://hub.docker.com/r/verdaccio/verdaccio/)
```bash
docker pull verdaccio/verdaccio
```
![Docker pull](/svg/docker_verdaccio.gif)
## 标记版本
自版本`v2.x`开始,您可以通过[标签](https://hub.docker.com/r/verdaccio/verdaccio/tags/)来下载(pull)docker镜像具体操作如下:
对于主版本:
```bash
docker pull verdaccio/verdaccio:3
```
对于次版本:
```bash
docker pull verdaccio/verdaccio:3.0
```
对于特定(补丁)版本:
```bash
docker pull verdaccio/verdaccio:3.0.1
```
下一个主版本将使用 `beta`(主分支)版本。
```bash
docker pull verdaccio/verdaccio:beta
```
> 如果您对标签列表感兴趣,[ 请访问 Docker 网站枢纽](https://hub.docker.com/r/verdaccio/verdaccio/tags/)。
## 用Docker运行verdaccio
要运行docker 容器:
```bash
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
```
最后一个参数定义要使用的镜像。如果您还没有试的话上面的代码将从dockerhub里下载(pull) 最新的预先创建的镜像。
如果您已经用 `verdaccio`作为最后参数[在本地创建一个镜像](#build-your-own-docker-image)。
您可以用 `-v`来绑定安装 `conf`, `storage``plugins`到主机文件系统中:
```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 \
-v $V_PATH/plugins:/verdaccio/plugins \
verdaccio/verdaccio
```
> 请注意Verdaccio 在容器内是作为non-root 用户端 (uid=100, gid=101) 运行, 如果您使用绑定安装来覆盖默认设置, 您需要确保安装目录是被指定到正确的用户端。 在上面的示例里,您要运行 `sudo chown -R 100:101 /opt/verdaccio`,否则在运行的时候您会得到权限错误提醒。 推荐[使用docker卷volume)](https://docs.docker.com/storage/volumes/)来替代绑定安装。
### 插件
插件可以在单独的目录里安装并用Docker或者Kubernetes挂载然而请确保使用与Verdaccio Dockerfile相同的基镜像的本地依赖项来创建插件。
### Docker和自定义端口配置
任何在 `listen`下的`conf/config.yaml` 里配置的`host:port` 目前在使用docker时都将被忽略。
如果您希望在不同的端口获得verdaccio docker instance比如 `docker run` 命令里的`5000`,请用 `-p 5000:4873`来取代`-p 4873:4873`
从版本2.?.? 开始, 假如您需要指定**docker 容器**内的监听端口, 您可以通过提供额外的参数给`docker run`: `--env PORT=5000`来达成。这将更改docker容器显示的端口以及verdaccio监听的端口。
当然您给出的`-p`参数数字必须吻合,因此,假设您希望它们全部都一样,这是您需要复制,黏贴和采用的代码:
```bash
PORT=5000; docker run -it --rm --name verdaccio \
--env PORT -p $PORT:$PORT
verdaccio/verdaccio
```
### HTTPS与Docker一同使用
您可以配置 verdaccio 要监听的协议,类似于端口配置。 在 config.yaml里指定证书后您必须用"https"覆盖`PROTOCOL` 环境变量中的默认值("http")。
```bash
PROTOCOL=https; docker run -it --rm --name verdaccio \
--env PROTOCOL -p 4873:4873
verdaccio/verdaccio
```
### 使用docker-compose
1. 获取[docker-compose](https://github.com/docker/compose)的最新版本。
2. 创建并运行容器:
```bash
$ docker-compose up --build
```
`PORT=5000`作为以上命令的前缀来设置要使用(容器和主机二者)的端口。
Docker将生成一个named volume命名卷它用于存储持续应用程序数据。 您可以使用`docker inspect` 或者 `docker volume inspect` 来查看此volume的物理位置并编辑配置比如
$ docker volume inspect verdaccio_verdaccio
[
{
"Name": "verdaccio_verdaccio",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/verdaccio_verdaccio/_data",
"Labels": null,
"Scope": "local"
}
]
## 创建您自己的Docker镜像
```bash
docker build -t verdaccio .
```
还有一个创建docker image镜像的npm脚本因此您还可以执行以下操作
```bash
npm run build:docker
```
请注意:第一个镜像的创建要花费几分钟时间,因为它需要运行`npm install`,而且,当您任何时候更改任何没有列在`.dockerignore`里的文件,它也需要运行那么长的时间。
如果您希望在rpi或兼容设备上使用docker镜像也有现成的dockerfile。要创建 raspberry pi树莓派的docker镜像请执行
```bash
npm run build:docker:rpi
```
请注意,您需要在您的机台上安装 docker 来执行以上任何docker命令 docker 执行项应该在您的`$PATH`里。
## Docker示例
有个分开的 repository资源库承载多个配置来用 `verdaccio`生成Docker镜像例如reverse proxy反向代理服务器:
<https://github.com/verdaccio/docker-examples>
## Docker 自定义创建
* [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) 专用 NPM 容器可以备份到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) coldrye-debian-nodejs支持的verdaccio docker镜像。