docker映像檔操作
===
(last update:2021/10/31)
## `docker`映像檔相關指令
### `docker`指令
```
build Build a new image from Dockerfile
commit Create a new image from a container's changes
images List images
import Import the contents from a tarball to create a filesystem image
load Load an image from a tar archive or STDIN
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rmi Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
```
### `docker image`指令
```
build Build an image from a Dockerfile
history Show the history of an image
import Import the contents from a tarball to create a filesystem image
inspect Display detailed information on one or more images
load Load an image from a tar archive or STDIN
ls List images
prune Remove unused images
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rm Remove one or more images
save Save one or more images to a tar archive (streamed to STDOUT by default)
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
```
### 總覽
* 建立:pull, commit
* 列出:ls
* 載入:load/import
* 上傳:push
* 刪除:rm/prune
* 存入:save
* 搜尋:search
* 更名:tag
* 登入Hub:login, logout
## 映像檔指令範例
**範例1:`docker images` or `docker image ls`**
顯示目前本機中有多少映像檔
```
(immust3)joshhu:~/ $ docker images [1:11:16]
REPOSITORY TAG IMAGE ID CREATED SIZE
joshhu/test-php-site latest 4bbd14cfc0a1 3 days ago 472MB
nvcr.io/nvidia/pytorch 20.08-py3 c710aa2340b4 14 months ago 12.2GB
nvcr.io/nvidia/tensorflow 20.08-tf1-py3 9ef087d45f32 14 months ago 11.9GB
wpscanteam/wpscan latest ea50f1bd15a4 17 months ago 104MB
moeaidb/aigo cpu-tf-20.03 ac2385e7b37d 20 months ago 5.05GB
moeaidb/aigo cpu-tf-cv-20.03 902057ca7a3c 20 months ago 7.62GB
moeaidb/aigo cu10.1-dnn7.6-gpu-tf-cv-19.12 cea568f0f30f 22 months ago 11GB
moeaidb/aigo cu10.1-dnn7.6-gpu-pytorch-cv-19.12 d8fbf8cb8b2c 22 months ago 11.6GB
moeaidb/aigo cu10.1-dnn7.6-gpu-tf-19.12 7233e721cb59 22 months ago 11.3GB
nvidia/cuda 10.2-base a6f6c250465c 23 months ago 108MB
nvidia/cuda 10.0-base 841d44dd4b3c 23 months ago 110MB
nvidia/cuda 10.1-base 3b55548ae91f 23 months ago 106MB
hello-world latest fce289e99eb9 2 years ago 1.84kB
atmoz/sftp latest 6345f82053c6 2 years ago 190MB
(immust3)joshhu:~/ $
```
**範例2:`docker pull <image>` or `docker image pull <image>`**
將雲端主機上的映像檔下載回本機
```
(joshhuAI)joshhu:~/ $ docker image ls [15:02:04]
REPOSITORY TAG IMAGE ID CREATED SIZE
(joshhuAI)joshhu:~/ $ docker pull busybox [15:02:06]
Using default tag: latest
latest: Pulling from library/busybox
01c2cdc13739: Pull complete
Digest: sha256:15e927f78df2cc772b70713543d6b651e3cd8370abf86b2ea4644a9fba21107f
Status: Downloaded newer image for busybox:latest
docker.io/library/busybox:latest
(joshhuAI)joshhu:~/ $ docker image ls [15:02:15]
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest cabb9f684f8b 2 days ago 1.24MB
(joshhuAI)joshhu:~/ $
```
其它範例:
```
docker pull joshhu/test-php-site:latest
```
**範例3:`docker image history <image>`**
列出一個映像檔的創建歷史,從新到舊,沒有`Dockerfile`時很好用
```
(joshhuAI)joshhu:~/ $ docker image history busybox [15:06:55]
IMAGE CREATED CREATED BY SIZE COMMENT
cabb9f684f8b 2 days ago /bin/sh -c #(nop) CMD ["sh"] 0B
<missing> 2 days ago /bin/sh -c #(nop) ADD file:88b76d15f53403ca2… 1.24MB
(joshhuAI)joshhu:~/ $ docker image history ubuntu [15:07:03]
IMAGE CREATED CREATED BY SIZE COMMENT
ba6acccedd29 2 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:5d68d27cc15a80653… 72.8MB
(joshhuAI)joshhu:~/ $
```
**範例4:`docker image save -o <tar file> <image>`**
將映像檔存入本機的`tar`檔案,不想用公開映像檔又沒自己的registry時很好用,可以用來轉移,備份等,通常配合`load`使用。
```
(joshhuAI)joshhu:~/ $ docker image save -o busybox.tar busybox:latest [15:13:06]
(joshhuAI)joshhu:~/ $ ll [15:13:08]
total 163M
drwxrwxr-x 26 joshhu joshhu 4.0K 1月 4 2020 anaconda3
lrwxrwxrwx 1 joshhu joshhu 10 7月 29 2020 Backup -> /mnt/disk2
-rw------- 1 joshhu joshhu 1.5M 10月 30 15:13 busybox.tar
drwxrwxr-x 4 joshhu joshhu 4.0K 11月 16 2020 cuda
drwxrwxr-x 2 joshhu joshhu 4.0K 1月 25 2021 deepmind
drwxr-xr-x 2 joshhu joshhu 4.0K 1月 26 2021 Desktop
drwxr-xr-x 5 joshhu joshhu 4.0K 9月 22 14:40 Downloads
-rw-r--r-- 1 joshhu joshhu 8.8K 11月 20 2019 examples.desktop
drwxrwxr-x 4 joshhu joshhu 4.0K 9月 26 02:20 mnt
drwxrwxr-x 3 joshhu joshhu 4.0K 9月 21 16:55 PhoenixMiner_5.6d_Linux
drwxr-xr-x 2 joshhu joshhu 4.0K 10月 26 16:49 Pictures
drwx------ 4 joshhu joshhu 4.0K 2月 6 2020 snap
drwxr-xr-x 3 joshhu joshhu 4.0K 2月 18 2021 Videos
drwx------ 11 joshhu joshhu 4.0K 8月 16 21:34 VirtualBox VMs
drwxr-xr-x 9 joshhu joshhu 4.0K 9月 22 19:46 VMs
-rw-rw-r-- 1 joshhu joshhu 161M 10月 11 18:40 wikititle.txt
drwxrwxr-x 30 joshhu joshhu 4.0K 10月 19 15:12 workspace
drwxr-xr-x 4 joshhu joshhu 4.0K 8月 20 00:36 xiaomi
-rw-r--r-- 1 joshhu joshhu 3.7K 10月 7 2020 zshrc.general
```
**範例5:`docker image load -i <tar file> <image>`**
將`tar`載入至本機映像檔中,配合`save`使用。
```
(joshhuAI)joshhu:~/ $ [15:15:41]
(joshhuAI)joshhu:~/ $ docker image ls [15:15:41]
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
(joshhuAI)joshhu:~/ $ docker image load -i busybox.tar [15:15:43]
a9ca537752fd: Loading layer 1.459MB/1.459MB
Loaded image: busybox:latest
(joshhuAI)joshhu:~/ $ docker images [15:15:49]
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest cabb9f684f8b 2 days ago 1.24MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
(joshhuAI)joshhu:~/ $
```
**範例6:`docker image import <tar file> <image>`**
將`tar`載入至本機映像檔中,配合`save`使用,如果沒有tag就會變成無名的映像檔。
```
(joshhuAI)joshhu:~/ $ docker images [22:21:14]
REPOSITORY TAG IMAGE ID CREATED SIZE
joshhu/bzbzbox latest c29ef9598cf2 7 hours ago 1.46MB
bzbox latest c29ef9598cf2 7 hours ago 1.46MB
bzbzbox latest c29ef9598cf2 7 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $ docker image import busybox.tar [22:21:16]
sha256:e2eab2ad8a743b53a3916b398a423f1bed92cdb25a5f6602d09f18f4c2442b1a
(joshhuAI)joshhu:~/ $ docker images [22:21:23]
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> e2eab2ad8a74 2 seconds ago 1.46MB
bzbzbox latest c29ef9598cf2 7 hours ago 1.46MB
joshhu/bzbzbox latest c29ef9598cf2 7 hours ago 1.46MB
bzbox latest c29ef9598cf2 7 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $
```
**範例7:`docker search <keyword>`**
在docker hub上搜尋映像檔,可以加星等。
```
(joshhuAI)joshhu:~/ $ docker search --filter=stars=20 mysql [20:16:40]
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11610 [OK]
mariadb MariaDB Server is a high performing open sou… 4417 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 857 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 91
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 89
centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]
databack/mysql-backup Back up mysql databases to... anywhere! 51
prom/mysqld-exporter 43 [OK]
deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK]
tutum/mysql Base docker image to run a MySQL database se… 35
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 33
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK]
mysql/mysql-router MySQL Router provides transparent routing be… 23
centos/mysql-56-centos7 MySQL 5.6 SQL database server 20
(joshhuAI)joshhu:~/ $
```
```
docker search --filter=is-automated=true --filter=stars=10 ubuntu
```
**範例8:`docker image rm <image>` or `docker rmi <image>`**
移除映像檔。
```
(joshhuAI)joshhu:~/ $ docker images [21:58:38]
REPOSITORY TAG IMAGE ID CREATED SIZE
bzbox latest c29ef9598cf2 6 hours ago 1.46MB
<none> <none> 1caa44c477a3 6 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $ docker rmi 1c [21:58:41]
Deleted: sha256:1caa44c477a3f89cc94f01d4ed24670ed75ba981ab68db8c65e577a69827cd1f
(joshhuAI)joshhu:~/ $ docker images [21:58:58]
REPOSITORY TAG IMAGE ID CREATED SIZE
bzbox latest c29ef9598cf2 6 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $
```
**範例9:`docker tag <image>` or `docker image tag <image>`**
映像檔打標籤。
```
(joshhuAI)joshhu:~/ $ docker images [22:00:30]
REPOSITORY TAG IMAGE ID CREATED SIZE
bzbox latest c29ef9598cf2 6 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $ docker tag bzbox bzbzbox [22:00:33]
(joshhuAI)joshhu:~/ $ docker images [22:01:07]
REPOSITORY TAG IMAGE ID CREATED SIZE
bzbox latest c29ef9598cf2 6 hours ago 1.46MB
bzbzbox latest c29ef9598cf2 6 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $
```
**範例10:`docker image inspect <image>`**
檢視映像檔的`json`格式詳情。
```json
(joshhuAI)joshhu:~/ $ docker image inspect bzbox [22:01:46]
[
{
"Id": "sha256:c29ef9598cf2ba23dac375432c62ee7d59ea54b3015c127539ffb9f8ec022cee",
"RepoTags": [
"bzbox:latest",
"bzbzbox:latest"
],
"RepoDigests": [],
"Parent": "",
"Comment": "Imported from -",
"Created": "2021-10-30T07:50:39.683186809Z",
"Container": "",
"ContainerConfig": {
"Hostname": "",
"Domainname": "",
.......(略)
```
**範例11:`docker image prune`**
刪除沒有名稱的映像檔。
```
(joshhuAI)joshhu:~/ $ docker images [22:05:38]
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> c60ce5178994 9 seconds ago 1.46MB
bzbzbox latest c29ef9598cf2 6 hours ago 1.46MB
bzbox latest c29ef9598cf2 6 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $ docker image prune [22:05:40]
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:c60ce51789943f08a85142afbacd82690e978eb774baa682252be961910b033b
Total reclaimed space: 0B
(joshhuAI)joshhu:~/ $ docker images [22:05:44]
REPOSITORY TAG IMAGE ID CREATED SIZE
bzbox latest c29ef9598cf2 6 hours ago 1.46MB
bzbzbox latest c29ef9598cf2 6 hours ago 1.46MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:~/ $
```
**範例12:`docker push <username/image>`**
將映像檔上傳至docker hub,要先有使用者名稱,上傳後只能從網頁上刪除。
```
(joshhuAI)joshhu:~/ $ docker image tag bzbzbox joshhu/bzbzbox [22:10:05]
(joshhuAI)joshhu:~/ $ docker push joshhu/bzbzbox [22:10:40]
Using default tag: latest
The push refers to repository [docker.io/joshhu/bzbzbox]
0afbaf233bfc: Pushed
latest: digest: sha256:003b4043404b0dbb12e2ab82307da3884ab8196499fb72762b0e99d5f44f3f27 size: 526
```

**範例13:`docker build`**
從`Dockerfile`自建一個映像檔。詳情見這裏:
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker build -t test-php-site . [22:28:23]
Sending build context to Docker daemon 119.8kB
Step 1/5 : FROM php:8.0-apache
8.0-apache: Pulling from library/php
7d63c13d9b9b: Pull complete
24b15dfd3cfa: Pull complete
64625c2e355f: Pull complete
275a8dd8f358: Pull complete
eb1c8ccc797a: Pull complete
0aaf98f0c33a: Pull complete
e6e7c544c3e3: Pull complete
6d2494716a7d: Pull complete
4f8b80d5b9af: Pull complete
ea6ae946fab9: Pull complete
c4aa6e057fc8: Pull complete
f9fc81d6b719: Pull complete
645a7d3fce0a: Pull complete
Digest: sha256:05e0776f39939336ba6cd14424bc0d1ff98dc1b20e3a4287515fd4decd8babc5
Status: Downloaded newer image for php:8.0-apache
---> 3249ab66a0fd
Step 2/5 : WORKDIR /var/www/html
---> Running in ca75cece8fd6
Removing intermediate container ca75cece8fd6
---> 9a5af0bc4514
Step 3/5 : COPY index.php index.php
---> 2000b1089319
Step 4/5 : COPY src/ src
---> f69c1b870a50
Step 5/5 : EXPOSE 80
---> Running in 34e4c011e460
Removing intermediate container 34e4c011e460
---> 82d82837d589
Successfully built 82d82837d589
Successfully tagged test-php-site:latest
```
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker images [22:29:32]
REPOSITORY TAG IMAGE ID CREATED SIZE
test-php-site latest 82d82837d589 49 seconds ago 472MB
<none> <none> e2eab2ad8a74 8 minutes ago 1.46MB
bzbzbox latest c29ef9598cf2 7 hours ago 1.46MB
joshhu/bzbzbox latest c29ef9598cf2 7 hours ago 1.46MB
bzbox latest c29ef9598cf2 7 hours ago 1.46MB
php 8.0-apache 3249ab66a0fd 8 days ago 472MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
dorowu/ubuntu-desktop-lxde-vnc latest 1a89db715923 6 months ago 1.32GB
(joshhuAI)joshhu:docker_test/ (main✗) $
```

**範例14:`docker commit`**
將一個現存的容器整個壓成一個映像檔,主要是檔案和目錄的更動
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker run -d -p 80:80 test-php-site [23:46:26]
8fa122c80f3cb186970c93103a790ebf9209cf937cfa7a36a9e3435685f31179
(joshhuAI)joshhu:docker_test/ (main✗) $ docker ps [23:46:35]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8fa122c80f3c test-php-site "docker-php-entrypoi…" 3 seconds ago Up 1 second 0.0.0.0:80->80/tcp, :::80->80/tcp quizzical_hoover
(joshhuAI)joshhu:docker_test/ (main✗) $
```
```
docker cp Vagrantfile 8f:/
(joshhuAI)joshhu:docker_test/ (main✗) $ docker exec 8f ls -al / [23:47:51]
total 80
drwxr-xr-x 1 root root 4096 Oct 30 15:47 .
drwxr-xr-x 1 root root 4096 Oct 30 15:47 ..
-rwxr-xr-x 1 root root 0 Oct 30 15:46 .dockerenv
-rw-rw-r-- 1 1000 1000 3018 Oct 27 06:34 Vagrantfile
drwxr-xr-x 1 root root 4096 Oct 12 04:45 bin
drwxr-xr-x 2 root root 4096 Oct 3 09:15 boot
drwxr-xr-x 5 root root 340 Oct 30 15:46 dev
drwxr-xr-x 1 root root 4096 Oct 30 15:46 etc
drwxr-xr-x 2 root root 4096 Oct 3 09:15 home
drwxr-xr-x 1 root root 4096 Oct 12 04:38 lib
drwxr-xr-x 2 root root 4096 Oct 11 00:00 lib64
drwxr-xr-x 2 root root 4096 Oct 11 00:00 media
drwxr-xr-x 2 root root 4096 Oct 11 00:00 mnt
drwxr-xr-x 2 root root 4096 Oct 11 00:00 opt
dr-xr-xr-x 498 root root 0 Oct 30 15:46 proc
drwx------ 1 root root 4096 Oct 21 15:30 root
drwxr-xr-x 1 root root 4096 Oct 12 04:45 run
drwxr-xr-x 1 root root 4096 Oct 12 04:45 sbin
drwxr-xr-x 2 root root 4096 Oct 11 00:00 srv
dr-xr-xr-x 13 root root 0 Oct 30 15:38 sys
drwxrwxrwt 1 root root 4096 Oct 21 15:30 tmp
drwxr-xr-x 1 root root 4096 Oct 11 00:00 usr
drwxr-xr-x 1 root root 4096 Oct 12 04:38 var
(joshhuAI)joshhu:docker_test/ (main✗) $
```
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker commit 8fa122c80f3c newimage [23:50:01]
sha256:f3f53b1d946762c1d1c0599b3b9fb4bc72aceb45cc58ff07e57db076477d3c79
(joshhuAI)joshhu:docker_test/ (main✗) $ docker images [23:50:17]
REPOSITORY TAG IMAGE ID CREATED SIZE
newimage latest f3f53b1d9467 4 seconds ago 472MB
test-php-site latest 82d82837d589 About an hour ago 472MB
php 8.0-apache 3249ab66a0fd 9 days ago 472MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
(joshhuAI)joshhu:docker_test/ (main✗) $
```
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker rm -f 8f [23:50:56]
8f
(joshhuAI)joshhu:docker_test/ (main✗) $ docker ps -a [23:51:03]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
(joshhuAI)joshhu:docker_test/ (main✗) $
```
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker run -d newimage [23:51:15]
781d1370a70ee9b2cd0b54ae0ae1a90acea648897e05307ad9232f4730bca6ca
(joshhuAI)joshhu:docker_test/ (main✗) $ docker ps [23:51:35]
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
781d1370a70e newimage "docker-php-entrypoi…" 3 seconds ago Up 2 seconds 80/tcp romantic_volhard
(joshhuAI)joshhu:docker_test/ (main✗) $
```
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker exec 78 ls -l / [23:51:47]
total 72
-rw-rw-r-- 1 1000 1000 3018 Oct 27 06:34 Vagrantfile
drwxr-xr-x 1 root root 4096 Oct 12 04:45 bin
drwxr-xr-x 2 root root 4096 Oct 3 09:15 boot
drwxr-xr-x 5 root root 340 Oct 30 15:51 dev
drwxr-xr-x 1 root root 4096 Oct 30 15:51 etc
drwxr-xr-x 2 root root 4096 Oct 3 09:15 home
drwxr-xr-x 1 root root 4096 Oct 12 04:38 lib
drwxr-xr-x 2 root root 4096 Oct 11 00:00 lib64
drwxr-xr-x 2 root root 4096 Oct 11 00:00 media
drwxr-xr-x 2 root root 4096 Oct 11 00:00 mnt
drwxr-xr-x 2 root root 4096 Oct 11 00:00 opt
dr-xr-xr-x 487 root root 0 Oct 30 15:51 proc
drwx------ 1 root root 4096 Oct 21 15:30 root
drwxr-xr-x 1 root root 4096 Oct 12 04:45 run
drwxr-xr-x 1 root root 4096 Oct 12 04:45 sbin
drwxr-xr-x 2 root root 4096 Oct 11 00:00 srv
dr-xr-xr-x 13 root root 0 Oct 30 15:38 sys
drwxrwxrwt 1 root root 4096 Oct 21 15:30 tmp
drwxr-xr-x 1 root root 4096 Oct 11 00:00 usr
drwxr-xr-x 1 root root 4096 Oct 12 04:38 var
```
**範例15:`docker login` or `docker logout`**
登入或登出docker hub,登入才可`push`映像檔。
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker logout [0:03:16]
Removing login credentials for https://index.docker.io/v1/
(joshhuAI)joshhu:docker_test/ (main✗) $ docker images [0:03:19]
REPOSITORY TAG IMAGE ID CREATED SIZE
newimage latest f3f53b1d9467 13 minutes ago 472MB
test-php-site latest 82d82837d589 2 hours ago 472MB
php 8.0-apache 3249ab66a0fd 9 days ago 472MB
ubuntu latest ba6acccedd29 2 weeks ago 72.8MB
(joshhuAI)joshhu:docker_test/ (main✗) $ docker tag test-php-site joshhu/test-php-site [0:03:30]
(joshhuAI)joshhu:docker_test/ (main✗) $ docker push joshhu/test-php-site [0:03:36]
Using default tag: latest
The push refers to repository [docker.io/joshhu/test-php-site]
e74387c60bed: Preparing
99083f54dc31: Preparing
2177609df867: Preparing
8ad38776536a: Preparing
1358d459bc17: Preparing
604feaf0ed22: Waiting
332bdfc2a1c7: Waiting
710c7c5af6a5: Waiting
3bcee7a79a82: Waiting
695add62b55d: Waiting
9e35cd071d08: Waiting
182cc4cf1598: Waiting
bb262ed90ed1: Waiting
b00cb208a75d: Waiting
e8b689711f21: Waiting
denied: requested access to the resource is denied
```
```
(joshhuAI)joshhu:docker_test/ (main✗) $ docker login [0:04:03]
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: joshhu
Password:
WARNING! Your password will be stored unencrypted in /home/joshhu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
(joshhuAI)joshhu:docker_test/ (main✗) $ docker push joshhu/test-php-site [0:04:16]
Using default tag: latest
The push refers to repository [docker.io/joshhu/test-php-site]
e74387c60bed: Pushed
99083f54dc31: Pushed
2177609df867: Layer already exists
8ad38776536a: Layer already exists
1358d459bc17: Layer already exists
604feaf0ed22: Layer already exists
332bdfc2a1c7: Layer already exists
710c7c5af6a5: Layer already exists
3bcee7a79a82: Layer already exists
695add62b55d: Layer already exists
9e35cd071d08: Layer already exists
182cc4cf1598: Layer already exists
bb262ed90ed1: Layer already exists
b00cb208a75d: Layer already exists
e8b689711f21: Layer already exists
latest: digest: sha256:4969dd83b4c2c4d7dc77a3d01e552f4e1928664aaed329b53a308653de89cc29 size: 3451
```
###### tags: `docker`, `docker images`, `容器`, `kubernetes`, `k8s`