Fork me on GitHub

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/my-first@sha256: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

 

 

posted on 2019-05-19 11:10  阳光-源泉  阅读(360)  评论(0编辑  收藏  举报

导航