LoginSignup
3
0

More than 5 years have passed since last update.

NexusでプライベートDockerリポジトリを作成

Last updated at Posted at 2019-04-25

環境

  • CentOS7
  • java 1.8.0_212

Nexus環境構築

1.アプリをダウンロード

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz

2.ダウンロードしたアプリを任意のディレクトリへ移動

sudo mv latest-unix.tar.gz /opt
cd /opt

3.対象ファイルを解凍、不要なファイルを削除、ディレクトリ名変更

sudo tar xvfz latest-unix.tar.gz
sudo rm -rf latest-unix.tar.gz
sudo mv nexus-3.16.1-02/ nexus3

4.権限変更

sudo chown -R centos:centos nexus3/ sonatype-work/

5.起動

nexus3/bin/nexus run

※「Started Sonatype Nexus.」がコンソールに出力されるまで待機
※「http://nexus-ip-address:8081/」へアクセス
※外部からアクセスする場合は、8081ポートの開放が必要

サインイン

  • デフォルトの管理ユーザー情報
ユーザー パスワード
admin admin123

Dockerリポジトリ作成

1.下記アイコンをクリック
image.png

2.下記アイコンをクリック
image.png

3.下記アイコンをクリック
image.png

4.下記アイコンをクリック
image.png

5.Dockerリポジトリ情報を設定
image.png
※ここでは

  • リポジトリ名をdocker-reposに設定
  • 8083ポートでHTTP公開

6.下記アイコンをクリック
image.png

Nexusへイメージをプッシュ(クライアント操作)

1.下記のファイルを/etc/dockerディレクトリへ作成

daemon.json
{
  "insecure-registries": ["nexus-ip-address:docker-repos-port"],
  "disable-legacy-registry": true
}

http://docs.docker.jp/engine/reference/commandline/dockerd.html
※今回の場合、docker-repos-portは8083

2.Dockerサービスを再起動

sudo systemctl restart docker

3.Dockerリポジトリへログイン

$ sudo docker login -u admin -p admin123 nexus-ip-address:docker-repos-port
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

4.プッシュしたいイメージに対して下記の形でタグを打つ

sudo docker tag target-image:target-tag nexus-ip-address:docker-repos-port/image:tag

5.プッシュ

sudo docker push nexus-ip-address:docker-repos-port/image:tag

参考URL

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0