Docker鏡像發佈到Docker Hub的實現方法

在使用docker過程中,往往會用到鏡像倉庫,方便管理的同時也方便在其他環境下快速下載鏡像,本文講解如何將鏡像傳入docker官方倉庫。操作系統以CentOS 8 為例講解如何將自己的鏡像上傳到docker hub。

一、Docker 官網註冊一個賬號,新建倉庫

二、制作鏡像,保存修改後的容器鏡像為例

# 本次不以docker build 為例
# docker ps -a
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
CONTAINER ID  IMAGE                                             COMMAND               CREATED        STATUS            PORTS                     NAMES
236cd97f7854  docker.io/oddrationale/docker-shadowsocks:latest  -s 0.0.0.0 -p 123...  4 seconds ago  Up 3 seconds ago  0.0.0.0:12345->12345/tcp  unruffled_hamilton
 
# 拷貝宿主的文件進容器/tmp目錄
# docker cp /data/shadowsock/config.json 236cd97f7854:/tmp
# docker commit 236cd97f7854 shadowsock-feb
# docker images
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY                                 TAG     IMAGE ID      CREATED       SIZE
localhost/shadowsock-feb                   latest  55c10922d371  18 hours ago  438 MB
docker.io/oddrationale/docker-shadowsocks  latest  4cbc49994ade  3 years ago   438 MB

三、鏡像上傳

# 重新打標簽,鏡像重命名使之與Docker Hub賬號倉庫匹配,格式: 用戶名/倉庫名
# docker tag 55c10922d371 skypipi/shadowsock
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
 
# docker images
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY                                 TAG     IMAGE ID      CREATED       SIZE
localhost/shadowsock-feb                   latest  55c10922d371  18 hours ago  438 MB
localhost/skypipi/shadowsock               latest  55c10922d371  18 hours ago  438 MB
docker.io/oddrationale/docker-shadowsocks  latest  4cbc49994ade  3 years ago   438 MB
 
 
# 指定 docker.io 地址,否則就登錄到redhat官網瞭
# docker login docker.io
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Username: skypipi
Password: 
Login Succeeded!
 
# docker push skypipi/shadowsock
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Getting image source signatures
.......
Copying config 55c10922d3 done  
Writing manifest to image destination
Storing signatures
 

四、鏡像下載

 通過官網下載

通過命令下載

# docker pull skypipi/shadowsock:latest

到此這篇關於Docker鏡像發佈到Docker Hub的實現方法的文章就介紹到這瞭,更多相關Docker鏡像發佈到Docker Hub內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: