LoginSignup
28
27

More than 5 years have passed since last update.

Docker Registryをさくっと立てる

Posted at

ローカル環境にDocker Registryをさくっと立てる方法
詳しくはこちら→https://github.com/dotcloud/docker-registry

立てる

$ docker pull stackbrew/registry

Docker Registryはオフィシャルのイメージを使用する。
https://registry.hub.docker.com/_/registry/Docker

$ docker run -d -p 5000:5000 -v /opt/docker_data/registry:/tmp/registry stackbrew/registry

データを永続化するためにホストのディレクトリをマウントする。
レジストリのデータは/tmp/registryにデータが保存されているので、適宜マウントする。
https://github.com/docker/docker-registry#persistent-storage

試す

Dockerfile
from centos:centos7

run yum install -y httpd
expose 80
cmd["/usr/sbin/httpd", "-D", "FOREGROUND"]
$ docker build --rm -t demo/httpd .

ひとまず、適当なイメージをビルドする。

$ docker tag demo/httpd localhost:5000/httpd
$ docker push localhost:5000/httpd

Docker Registryへpushを行うにはタグを設定する必要があるため、
先ほど作成したdemo/httpdlocalhost:5000/httpdを設定する
タグにはDocker Registryのホスト名とポートを指定する。

$ docker rmi localhost:5000/httpd
$ docker pull localhost:5000/httpd

一旦イメージを削除して、Docker Registryからpullする

$ docker run -d -p 80:80 -P localhost:5000/httpd

起動確認をして終了

28
27
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
28
27