Installation - Insecure(No Authentication)
# image
REGISTRY=registry
VERSION=2.8.3
docker pull ${REGISTRY}:${VERSION}
docker images | grep registry
# data directory
REGISTRY_DIR=/data
sudo mkdir -pv $REGISTRY_DIR
# container parameter
REGISTRY_PORT=5000
container_name=registry
# run container
docker rm -f $container_name
docker run -d \
-p $REGISTRY_PORT:$REGISTRY_PORT \
--name $container_name \
--volume=${REGISTRY_DIR}:/var/lib/registry \
-e "REGISTRY_STORAGE_DELETE_ENABLED=true" \
${REGISTRY}:${VERSION}
- check
docker ps -a | grep registry
docker logs registry --tail=50 -f
Usage
- localhost
docker tag ${REGISTRY}:${VERSION} localhost:5000/${REGISTRY}:${VERSION}
docker push localhost:5000/${REGISTRY}:${VERSION}
参考文档
搭建自己的镜像仓库
Docker 默认是以 HTTPS 方式连接除 localhost 之外的仓库的,当从其他机器访问这个不安全的仓库地址时,需要修改 Docker 的配置文件/etc/docker/daemon.json
,将这个地址添加到 insecure-registries
配置项中:
{
"insecure-registries": ["registry.docker.dev.com", "registry.docker.dev.com:5000"]
}
然后重启 Docker
sudo vim /etc/docker/daemon.json
sudo systemctl reload docker.service
# sudo systemctl restart docker
# systemctl status docker
将192.168.x.x registry.docker.dev.com
配置到/etc/hosts
中,然后可以使用统一的域名前缀registry.docker.dev.com:5000
访问仓库。