Centos 7 安装 Docker | 菠萝焖鸭的日常分享 (wxhnyfy.site)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum -y install python3-pip -y
# 清华大学开源软件镜像站的pypi的加速 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose
docker-compose -v
github地址:https://github.com/goharbor/harbor/release
wget https://github.com/goharbor/harbor/releases/download/v2.4.3/harbor-offline-installer-v2.4.3.tgz
tar -zxvf harbor-offline-installer-v2.4.3.tgz
Harbor安装目录下操作
cd harbor cp harbor.yml.tmpl harbor.yml vim harbor.yml
修改hostname、http端口,https的部分可以暂时屏蔽。
修改默认密码、harbor数据存储地址。
# 创建harbor数据存储地址 mkdir /mydata mkdir /mydata/harbor
./prepare
./install.sh
ERROR: for registry Cannot create container for service registry: Conflict. The container name "/registry" is already in use by container "28eb36d6bc5ebebf45a07fbfb4ae14159397d28a3fed64abbd560f71c8b658cb". You have to remove (or rename) that container to be able to reuse that name.
已经有了名为“registry”的容器。需要删除名为“registry”的容器。
docker stop registry docker rm -f registry ./install.sh
安装成功
访问地址(harbor.yml设置的是80端口):http://192.168.102.131 账号密码:admin/Harbor12345
Harbor 安装目录下执行
##启动 docker-compose up -d ##停止 docker-compose stop ##重新启动 docker-compose restart #用端口监听可以查看服务是否启动,端口是harbor.yml设置的80端口 netstat -tunlp|grep 80
可以创建一个简单的shell脚本
path=`pwd` cd /root/harbor case $1 in "start") docker-compose up -d ;; "stop") docker-compose stop ;; "restart") docker-compose restart ;; *) echo "参数为空或参数错误!" ;; esac cd $path
在客户机上操作,先登录,再推送镜像。
登录命令
docker login 192.168.102.131
输入 用户、密码
出现 Error response from daemon: Get "https://192.168.102.131/v2/": dial tcp 192.168.102.131:443: connect: connection refused 错误
vim /etc/docker/daemon.json
{ "max-concurrent-downloads": 3, "max-concurrent-uploads": 5, "insecure-registries": ["192.168.102.131"] }
systemctl daemon-reload systemctl restart docker
启动Harbor
cd /root/harbor docker-compose up -d
docker login 192.168.102.131
访问地址(harbor.yml设置的是80端口):http://192.168.102.131 账号密码:admin/Harbor12345
docker pull mysql:5.7.39 docker tag mysql:5.7.39 192.168.102.131/wxhntmy/mysql:5.7.39 docker images docker push 192.168.102.131/wxhntmy/mysql:5.7.39
获取拉取命令
docker pull 192.168.102.131/wxhntmy/mysql@sha256:5ecf646122c4fcbda81983c9e93e81a011b0593c9c19fbfc55b48bd1c23bc790
启动容器
docker run --name mysql \ -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d \ 192.168.102.131/wxhntmy/mysql@sha256:5ecf646122c4fcbda81983c9e93e81a011b0593c9c19fbfc55b48bd1c23bc790