docker安装和hub

Posted createyuan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker安装和hub相关的知识,希望对你有一定的参考价值。

 

 

 

yum install wget
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates|sort -r
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl status docker -l
docker run hello-world
systemctl enable docker

=======================

docker info

=======================
这就是完整的过程
编辑dockerfile文件》登录公共registry》build》本地运行》推送》其它机器拉取


cat > Dockerfile <<EOF
FROM busybox
CMD echo "Hello world! This is my first Docker image."
EOF

docker login
如果没有打a1这个标签,默认就是latest
docker build -t createyuan/my-first:a1 .
最后要加上一个dockerfile文件的路径,在当前目录下,也要指定./,不然报错

加速一下(配置国内镜像站点),不然会报TLS handshake timeout错误
echo "DOCKER_OPTS=\"--registry-mirror=https://registry.docker-cn.com\"" >> /etc/default/docker

systemctl status docker -l
systemctl restart docker
systemctl status docker -l

docker build -t createyuan/my-first:a1 .
docker run createyuan/my-first:a1

有时推送不成功,多试几次,试了三次
第一次net/http: TLS handshake timeout
第二次read tcp 192.168.7.201:41794->104.18.124.25:443: read: connection reset by peer
第三次a1: digest: sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e size: 527

docker push createyuan/my-first:a1

The push refers to repository [docker.io/createyuan/my-first]
d1156b98822d: Mounted from library/busybox
a1: digest: sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e size: 527

=========================
删除本地的镜像
docker image ls
docker rmi -f e3303b21e364
或者
docker rmi -f createyuan/my-first:a1

Untagged: createyuan/my-first:a1
Untagged: createyuan/[email protected]:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e
Deleted: sha256:e3303b21e364adb0df734ac558f07cfcaeab1e4d6a5db87d4b03fcd90a2d37bb

运行,结果就是重新拉取镜像
docker run createyuan/my-first:a1
Unable to find image ‘createyuan/my-first:a1‘ locally
a1: Pulling from createyuan/my-first
53071b97a884: Already exists
Digest: sha256:5738039995376e9eac8be145ffde81fe5781f6385406cd2c2deb7352e940369e
Status: Downloaded newer image for createyuan/my-first:a1
Hello world! This is my first Docker image.
=============================
构建第二个版本
docker build -t createyuan/my-first:a2 .
推送第二个版本
docker push createyuan/my-first:a2
运行
docker run createyuan/my-first:a2

 

 

以上是关于docker安装和hub的主要内容,如果未能解决你的问题,请参考以下文章

基于docker registry镜像安装私服docker hub

写最好的Docker安装最新版MySQL8(mysql-8.0.31)教程(参考Docker Hub和MySQL官方文档)

docker(14):centos7 安装docker hub harbor,可视化registry

Docker 更换国内的Hub源

docker容器从入门到实战0826

制作自己的docker镜像并上传到hub.docker