docker 建立自己的映象(五)

2021-10-01 22:32:58 字數 2000 閱讀 6164

首先,在上註冊自己的帳號,例如帳號是(test_a),留著後台上傳自己的映象至hub時用。

vim dockerfile
寫乙個很簡單的內容:

from centos

add jdk-8u191-linux-x64.tar.gz /usr/local/

複製centos映象,將與dockerfile檔案相同目錄下的這個檔案(也可以是資料夾)jdk-8u191-linux-x64.tar.gz,新增至虛擬機器下/usr/local/

wq
儲存退出

docker build -t test_a/centos_test .
結果:

[master@master test]$ docker build -t test_a/centos .

sending build context to docker daemon 1.051gb

step 1/2 : from centos

---> 0f3e07c0138f

step 2/2 : add jdk-8u191-linux-x64.tar.gz /usr/local/

---> using cache

---> 5fa9985ff9bd

successfully built 5fa9985ff9bd

successfully tagged test_a/centos:latest

映象就建立好了,使用命令檢視映象:

[master@master test]$ docker images

repository tag image id created size

test_a/centos latest 5fa9985ff9bd 10 days ago 616mb

nginx latest 540a289bab6c 2 months ago 126mb

centos latest 0f3e07c0138f 3 months ago 220mb

如果要上傳hub,需要登入帳號:

[master@master test]$ docker login

authenticating with existing credentials...

warning! your password will be stored unencrypted in /home/test/.docker/config.json.

configure a credential helper to remove this warning. see

login succeeded

我這邊已經登入好了,步驟很簡單。

接著使用命令上傳映象:

[master@master test]$ docker push test_a/centos_test

the push refers to repository [docker.io/mondu/centos_test]

7c2429fb***x: pushed

1436e4***xx: pushed

1b1d55***xx: pushed

904167***xx: pushed

9e607b***xx: mounted from library/centos

latest: digest: sha256:1f1a83***xxb7ede8bca***xx... size: 4544

再到自己的hub帳號下,就可以看到這個映象了。

建立自己的Docker基礎映象

本文講解如何在本地構建乙個基礎的docker python環境映象,並擴充套件這個基礎映象構建python執行環境,之後再構建自己的python應用。docker 提供了兩種方法來建立基礎映象,一種是通過引入tar包的形式,另外一種是通過乙個空白的映象來一步一步構建,本文使用的是第二種方法,既fro...

Docker 建立自己的阿里映象庫

前提 你需要有阿里的賬號 訪問阿里映象庫 阿里雲docker倉庫 設定映象庫register密碼 登入位址在我們剛開通的阿里賬號選單裡面,如下圖 sudo docker login username 2421499075 qq.com registry.cn shanghai.aliyuncs.co...

docker映象的建立

自己建立映象 docker search 映象名 eg.docker search centos可以看到映象名 作者資訊 是否為官方 建立時間 大小等資訊 docker pull 映象名 標籤名 eg.docker pull centos latestfrom 作為基礎的映象名 maintainer...