1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-17 07:45:52 +01: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

6.0 KiB
Raw Blame History

id title
docker Docker
![alt Docker Pulls Count](http://dockeri.co/image/verdaccio/verdaccio "Docker Pulls Count")

要下载(pull)最新的预先-创建的docker镜像

docker pull verdaccio/verdaccio

Docker pull

标记版本

自版本v2.x开始,您可以通过标签来下载(pull)docker镜像具体操作如下:

对于主版本:

docker pull verdaccio/verdaccio:3

对于次版本:

docker pull verdaccio/verdaccio:3.0

对于特定(补丁)版本:

docker pull verdaccio/verdaccio:3.0.1

下一个主版本将使用 beta(主分支)版本。

docker pull verdaccio/verdaccio:beta

如果您对标签列表感兴趣, 请访问 Docker 网站枢纽

用Docker运行verdaccio

要运行docker 容器:

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

最后一个参数定义要使用的镜像。如果您还没有试的话上面的代码将从dockerhub里下载(pull) 最新的预先创建的镜像。

如果您已经用 verdaccio作为最后参数在本地创建一个镜像

您可以用 -v来绑定安装 conf, storageplugins到主机文件系统中:

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)来替代绑定安装。

插件

插件可以在单独的目录里安装并用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参数数字必须吻合,因此,假设您希望它们全部都一样,这是您需要复制,黏贴和采用的代码:

PORT=5000; docker run -it --rm --name verdaccio \
  --env PORT -p $PORT:$PORT
  verdaccio/verdaccio

HTTPS与Docker一同使用

您可以配置 verdaccio 要监听的协议,类似于端口配置。 在 config.yaml里指定证书后您必须用"https"覆盖PROTOCOL 环境变量中的默认值("http")。

PROTOCOL=https; docker run -it --rm --name verdaccio \
  --env PROTOCOL -p 4873:4873
  verdaccio/verdaccio

使用docker-compose

  1. 获取docker-compose的最新版本。
  2. 创建并运行容器:
$ 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镜像

docker build -t verdaccio .

还有一个创建docker image镜像的npm脚本因此您还可以执行以下操作

npm run build:docker

请注意:第一个镜像的创建要花费几分钟时间,因为它需要运行npm install,而且,当您任何时候更改任何没有列在.dockerignore里的文件,它也需要运行那么长的时间。

如果您希望在rpi或兼容设备上使用docker镜像也有现成的dockerfile。要创建 raspberry pi树莓派的docker镜像请执行

npm run build:docker:rpi

请注意,您需要在您的机台上安装 docker 来执行以上任何docker命令 docker 执行项应该在您的$PATH里。

Docker示例

有个分开的 repository资源库承载多个配置来用 verdaccio生成Docker镜像例如reverse proxy反向代理服务器:

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

Docker 自定义创建