カテゴリー
【Dockerで開発環境構築】Verdaccio on DockerでコンテナのローカルIPを調べる方法
※ 当ページには【広告/PR】を含む場合があります。
2020/04/27
2021/05/10
はじめに〜バージョンアップデートで躓く話(※2021年5月更新)
$ npm adduser --registry http://192.168.32.1:4873
npm notice Log in on http://192.168.32.1:4873/
Username: *****
Password:
Email: (this IS public) ****
Logged in as **** on http://192.168.32.1:4873/.
npm notice
npm notice package: @my/**********
npm notice === Tarball Contents ===
#...中略
npm notice
npm ERR! code E500
npm ERR! 500 Internal Server Error - PUT http://192.168.32.1:4873/@my%2f*********** - internal server error
npm ERR! A complete log of this run can be found in:
npm ERR! /home/******/.npm/_logs/2021-05-10T06_01_39_320Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
基本的な立ち上げ方〜直接Shell画面でみる
$ docker run -it --rm \
--name verdaccio \
-p 4873:4873 \
verdaccio/verdaccio
version: '3'
services:
verdaccio:
image: verdaccio/verdaccio:5
container_name: verdaccio-local
ports:
- "4873:4873"
volumes:
- "./storage:/verdaccio/storage"
- "./conf:/verdaccio/conf"
restart: always
volumes:
verdaccio:
driver: local
$ docker-compose up
Creating network "verdaccio_docker_default" with the default driver
Creating verdaccio-local ... done
Attaching to verdaccio-local
verdaccio-local |
...
http://localhost:4873
verdaccio-local | info <-- 192.168.32.1 requested 'GET /'
verdaccio-local | http <-- 304, user: null(192.168.32.1), req: 'GET /', bytes: 0/0
verdaccio-local | http <-- 304, user: null(192.168.32.1), req: 'GET /', bytes: 0/0
#...
#以下略
$ docker-compose down
Verdaccio Docker コンテナのIPを調べる
http://localhost:4873
$ docker-compose up -d
$ docker ps | grep verd
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8665cf056ad7 verdaccio/verdaccio:5 "uid_entrypoint /bin…" 19 minutes ago Up 3 minutes 0.0.0.0:4873->4873/tcp verdaccio-local
dockerコマンドの正規な作法でIP確認
#With Container ID (ID値に重複がなければ短縮OK)
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 866
192.168.32.2
#Or, With Image Name
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' verdaccio-local
192.168.32.2
'192.168.32.2'
'192.168.32.1'
'192.168.32.2'
docker0
'192.168.32.1'
#With Container ID (ID値に重複がなければ短縮OK)
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' 866
192.168.32.1
#Or, With Image Name
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.Gateway}}{{end}}' verdaccio-local
192.168.32.1
ちょっと荒っぽいけど簡単なIP確認
docker inspect
--format
#With Container ID (コンテナID値に重複がなければ短縮OK)
$ docker inspect 866 | grep Gate
"Gateway": "",
"IPv6Gateway": "",
"Gateway": "192.168.32.1",
"IPv6Gateway": "",
#Or, With Image Name
$ docker inspect verdaccio-local | grep Gate
"Gateway": "",
"IPv6Gateway": "",
"Gateway": "192.168.32.1",
"IPv6Gateway": "",
npmパッケージをVerdaccioレジストリへパブリッシュ
#👇ユーザーの登録(ユーザ名・パスワード・emailアドレス)
$ npm adduser --registry http://{コンテナIP}:4873
#👇npmパッケージをVerdaccio側へアップロード
$ npm publish --registry http://{コンテナIP}:4873
docker-compose up
$ docker-compose up
Creating network "verdacciodocker_default" with the default driver
Creating verdaccio-local ...
Creating verdaccio-local ... done
Attaching to verdaccio-local
verdaccio-local | warn --- config file - /verdaccio/conf/config.yaml
verdaccio-local | (node:8) Warning: deprecate: multiple logger configuration is deprecated, please check the migration guide.
verdaccio-local | (Use `node --trace-warnings ...` to show where the warning was created)
verdaccio-local | warn --- Plugin successfully loaded: verdaccio-htpasswd
verdaccio-local | warn --- Plugin successfully loaded: verdaccio-audit
verdaccio-local | warn --- http address - http://0.0.0.0:4873/ - verdaccio/5.0.4
check the migration guide.
@hoge/piyo
scoped package
/verdaccio/conf/config.yaml
@my/なんとか
packages
packages:
'@jota/*':
access: $all
publish: $all
#👇スコープ付きパッケージの追加
"@my/*":
access: $all
publish: $all
'@*/*':
# scoped packages
access: $all
publish: $all
proxy: npmjs
#...中略
verdaccio-local | info --- ********** is allowed publish for @my/hoge
verdaccio-local | error--- unexpected error: EACCES: permission denied, open '/verdaccio/storage/@my/hoge/hoge.tgz.tmp-189143654945658'
verdaccio-local | Error: EACCES: permission denied, open '/verdaccio/storage/@my/hoge/hoge.tgz.tmp-189143654945658'
verdaccio-local | http --- 500, user: **********(192.168.32.1), req: 'PUT /@my%2fhoge', error: internal server error
verdaccio-local | http --- 192.168.32.1 requested 'PUT /@my%2fhoge'
verdaccio-local | info --- auth/allow_action: access granted to: undefined
verdaccio-local | info --- ********** is allowed publish for @my/hoge
verdaccio-local | error--- unexpected error: EACCES: permission denied, open '/verdaccio/storage/@my/hoge/hoge.tgz.tmp-017407823939065148'
verdaccio-local | Error: EACCES: permission denied, open '/verdaccio/storage/@my/hoge/hoge.tgz.tmp-017407823939065148'
verdaccio-local | http --- 500, user: **********(192.168.32.1), req: 'PUT /@my%2fhoge', error: internal server error
EACCES: permission denied
Verdaccioコンテナにファイル書き込み権限を与える
$ docker exec -it --user=root verdaccio-local /bin/sh
/opt/verdaccio#
/opt/verdaccio# ls -la /verdaccio/
total 20
drwxr-xr-x 1 root root 4096 Apr 28 05:21 .
drwxr-xr-x 1 root root 4096 May 10 06:55 ..
drwxr-xr-x 2 node node 4096 May 10 00:45 conf
drwxr-xr-x 2 root root 4096 Apr 28 05:21 plugins
drwxr-xr-x 10 node node 4096 May 10 01:12 storage
conf
storage
node
verdaccio
nogroup
/verdaccio
/opt/verdaccio# chown -R verdaccio:nogroup /verdaccio/
/opt/verdaccio# ls -la /verdaccio/
total 24
drwxr-xr-x 1 verdacci nogroup 4096 Apr 28 05:21 .
drwxr-xr-x 1 root root 4096 May 10 06:55 ..
drwxr-xr-x 2 verdacci nogroup 4096 May 10 00:45 conf
drwxr-xr-x 1 verdacci nogroup 4096 Apr 28 05:21 plugins
drwxr-xr-x 10 verdacci nogroup 4096 May 10 01:12 storage
$ npm adduser --registry http://192.168.32.1:4873
npm notice Log in on http://192.168.32.1:4873/
Username: ***********
Password:
Email: (this IS public) dave@osakavacuum.com
Logged in as *********** on http://192.168.32.1:4873/.
npm notice
npm notice package: @my/hoge
npm notice === Tarball Contents ===
#...中略
npm notice total files: 66
npm notice
+ @my/hoge
Done in 5.59s.
参考
記事を書いた人
ナンデモ系エンジニア
主にAngularでフロントエンド開発することが多いです。 開発環境はLinuxメインで進めているので、シェルコマンドも多用しております。 コツコツとプログラミングするのが好きな人間です。
カテゴリー