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
相關文章
相關標籤/搜索