docker memo

◾️ lifecycle (docker site) – lecture site

◾️ docker image(ex-nginx) search / pull / check download image

$ docker search nginx
NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
nginx                              Official build of Nginx.                        14455     [OK]
jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   1966                 [OK]
richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   807                  [OK]
jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   147
linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   141
tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   113                  [OK]
bitnami/nginx                      Bitnami nginx Docker Image                      94                   [OK]
.....

$ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
45b42c59be33: Pull complete
8acc495f1d91: Pull complete
ec3bd7de90d7: Pull complete
19e2441aeeab: Pull complete
f5a38c5f8d4e: Pull complete
83500d851118: Pull complete
Digest: sha256:f3693fe50d5b1df1ecd315d54813a77afd56b0245a404055a946574deb6b34fc
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
$ docker images
REPOSITORY          TAG       IMAGE ID       CREATED       SIZE
alpine/git          latest    a939554ad0d0   9 hours ago   25.1MB
nginx               latest    35c43ace9216   2 days ago    133MB
consol/tomcat-7.0   latest    7c34bafd1150   5 years ago   601MB

◾️ docker image run ( docker run = docker create + docker start )

-p 81:80 (81->80 port forwarding)

$ docker create -p 81:80 --name nx nginx
cc4d76cdc459b0c02db24552c1f23d514d28d9a06133cdfac12239037afcb205
$ docker ps -a
CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS                   PORTS                              NAMES
cc4d76cdc459   nginx               "/docker-entrypoint.…"   34 seconds ago   Created                                                     nx

$ docker start cc4d76cdc459
cc4d76cdc459
$ docker ps
CONTAINER ID   IMAGE               COMMAND                  CREATED         STATUS          PORTS                              NAMES
cc4d76cdc459   nginx               "/docker-entrypoint.…"   3 minutes ago   Up 54 seconds   0.0.0.0:81->80/tcp                 nx

◾️ delete docker container (docker stop and remove)

$ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                NAMES
cc4d76cdc459   nginx     "/docker-entrypoint.…"   9 minutes ago   Up 6 minutes   0.0.0.0:81->80/tcp   nx
$ docker stop cc4d76cdc459
cc4d76cdc459
$ docker rm cc4d76cdc459
cc4d76cdc459

◾️ remove docker image (docker rmi)

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
nginx        latest    35c43ace9216   2 days ago   133MB
$ docker rmi nginx
Untagged: nginx:latest
Untagged: nginx@sha256:f3693fe50d5b1df1ecd315d54813a77afd56b0245a404055a946574deb6b34fc
Deleted: sha256:35c43ace9216212c0f0e546a65eec93fa9fc8e96b25880ee222b7ed2ca1d2151
Deleted: sha256:61f2666cb67e4572a31412367fa44567e6ac238226385762ea65670ed39034a8
Deleted: sha256:622fb7fb6a35078e3a2d446bb0e74c6a0cd500e3a211fd17ecbbcea5377ded38
Deleted: sha256:69a8591f1aaa7d694fa79a187886f6690e6e51e8c2bc91727be01a9e87daacd2
Deleted: sha256:8a451c701633832102e10093db7545eada8e5639a1b35bb14afaf48601948802
Deleted: sha256:2edbde38832e9e0e07d113df74817dc736fd49ea2f9c0d7ce8e40e3446b49b82
Deleted: sha256:9eb82f04c782ef3f5ca25911e60d75e441ce0fe82e49f0dbf02c81a3161d1300
$ docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
$

◾️ docker layer

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
nginx        latest    35c43ace9216   2 days ago   133MB
$ docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  scan: Docker Scan (Docker Inc., v0.5.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 20.10.2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
 runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.121-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 1.944GiB
 Name: docker-desktop
 ID: VVD5:6N75:M26Z:XF3R:7UCU:TPUC:SVU3:CWQP:SDUD:CKEK:S7UO:AZXG
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: gateway.docker.internal:3128
 HTTPS Proxy: gateway.docker.internal:3129
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
nginx        latest    35c43ace9216   2 days ago   133MB
$ docker inspect nginx
[
    {
        "Id": "sha256:35c43ace9216212c0f0e546a65eec93fa9fc8e96b25880ee222b7ed2ca1d2151",
        "RepoTags": [
            "nginx:latest"
        ],
        "RepoDigests": [
            "nginx@sha256:f3693fe50d5b1df1ecd315d54813a77afd56b0245a404055a946574deb6b34fc"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2021-02-17T19:20:26.056161789Z",
        "Container": "51caab8ab3beefe704d8b6fbe7653b2c7df216cd44787aca26bc5c6a2e2e9414",
        "ContainerConfig": {
            "Hostname": "51caab8ab3be",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.19.7",
                "NJS_VERSION=0.5.1",
                "PKG_RELEASE=1~buster"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"nginx\" \"-g\" \"daemon off;\"]"
            ],
            "Image": "sha256:082b9a998c25c1b35b2d7c19b5181e5c7daea5c39f403c25a9076adb9d3613a2",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
            },
            "StopSignal": "SIGQUIT"
        },
        "DockerVersion": "19.03.12",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "NGINX_VERSION=1.19.7",
                "NJS_VERSION=0.5.1",
                "PKG_RELEASE=1~buster"
            ],
            "Cmd": [
                "nginx",
                "-g",
                "daemon off;"
            ],
            "Image": "sha256:082b9a998c25c1b35b2d7c19b5181e5c7daea5c39f403c25a9076adb9d3613a2",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "/docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
            },
            "StopSignal": "SIGQUIT"
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 133050457,
        "VirtualSize": 133050457,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/ceca45cbc5a4589e8a71f23893b9a4ab0f423b2696e90d743d1038bdc45c54d8/diff:/var/lib/docker/overlay2/d2254442716af1b2ebbe3aada30e60962a0d12ab572a8e48965a97edd7397d68/diff:/var/lib/docker/overlay2/b2c7dfea13becb345f5fc14188b7141b0db1e0c256ef6f2e809908ac7bf4d13a/diff:/var/lib/docker/overlay2/d397fd20a87a288dc58848667079f6c55389abbd3ca22b1f2621bb9cd145eff0/diff:/var/lib/docker/overlay2/1f6805917ca04d68363e969f61aedc90684638b404608602ef34516731fcc5a7/diff",
                "MergedDir": "/var/lib/docker/overlay2/d6c8eeb46c2a987d51888be8b4e0a71a85b33cb703236acb8549726fb51b7d15/merged",
                "UpperDir": "/var/lib/docker/overlay2/d6c8eeb46c2a987d51888be8b4e0a71a85b33cb703236acb8549726fb51b7d15/diff",
                "WorkDir": "/var/lib/docker/overlay2/d6c8eeb46c2a987d51888be8b4e0a71a85b33cb703236acb8549726fb51b7d15/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:9eb82f04c782ef3f5ca25911e60d75e441ce0fe82e49f0dbf02c81a3161d1300",
                "sha256:ffd3d6313c9b2905d7cbb9011d8a4fbb0b67d6f334a194ab2f70cf0894b7f4f7",
                "sha256:9b23c8e1e6f9c47ceb8dc619d7f63d659369dedf159e0f9735478c0e41febcc6",
                "sha256:0f804d36244da89e06210c5424c217c9ad838ce91300de213fc25d10fce53c6a",
                "sha256:9f65d1d4c869b7f2910d4c30bb2eade88975529b363089b5a27821fd4c3ff1c7",
                "sha256:2acf82036f3853e985033bab258dabbeed795a98198263fc6a327ca4d1744f0d"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

◾️ internal shell in container

$ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                      PORTS     NAMES
a6437393cf06   nginx     "/docker-entrypoint.…"   12 minutes ago   Exited (0) 10 minutes ago             nx
$ docker start nx
nx
$ docker exec -it nx /bin/bash
root@a6437393cf06:/# ls
bin  boot  dev	docker-entrypoint.d  docker-entrypoint.sh  etc	home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

◾️ container log

$ docker logs nx
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
172.17.0.1 - - [20/Feb/2021:14:56:05 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" "-"
2021/02/20 14:56:05 [error] 32#32: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 172.17.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost", referrer: "http://localhost/"
172.17.0.1 - - [20/Feb/2021:14:56:05 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" "-"
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up

◾️ copy file (host to container / container to host / container to container)

$ echo "abc" > temp.txt
$ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                NAMES
a6437393cf06   nginx     "/docker-entrypoint.…"   23 minutes ago   Up 10 minutes   0.0.0.0:80->80/tcp   nx

$ docker cp temp.txt nx:/

$ docker exec -it nx cat /temp.txt
abc

$ docker exec -it nx /bin/bash
root@a6437393cf06:/# ls
bin  boot  dev	docker-entrypoint.d  docker-entrypoint.sh  etc	home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  temp.txt  tmp  usr	var
root@a6437393cf06:/#

$ docker cp nx:/temp.txt ./temp1.txt
$ cat ./temp1.txt
abc
$

◾️ all docker container id : all stop / all remove container

$ docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                NAMES
acc14c719a27   nginx     "/docker-entrypoint.…"   30 seconds ago   Up 29 seconds   0.0.0.0:81->80/tcp   nx2
a6437393cf06   nginx     "/docker-entrypoint.…"   32 minutes ago   Up 19 minutes   0.0.0.0:80->80/tcp   nx
$ docker ps -a -q
acc14c719a27
a6437393cf06
$ docker stop `docker ps -a -q`
acc14c719a27
a6437393cf06
$ docker rm `docker ps -a -q`
acc14c719a27
a6437393cf06
$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

◾️ docker –rm (remove container when docker stop)

$ docker run -d -p 80:80 --rm --name nx nginx
77e2ca4ddf6cc80bdd608d0cdbab939d9bf32e4a31dc679b6ad96780216afe20
$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                NAMES
77e2ca4ddf6c   nginx     "/docker-entrypoint.…"   12 seconds ago   Up 11 seconds   0.0.0.0:80->80/tcp   nx
$ docker stop nx
nx
$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$

◾️ volume mount (host to container)

$ mkdir share
$ cd share
$ echo "hello" > hello.txt
$ echo "hello" > hello1.txt
$ echo "hello" > hello2.txt
$
$ docker run -d -p 80:80 --rm -v /Users/username/share:/user/share/nginx/html:rw nginx
7e87e709164a096c89d6f51033134b7541a12eedf5df45ae855456100c18c019
$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                               NAMES
7e87e709164a   nginx     "/docker-entrypoint.…"   35 seconds ago   Up 33 seconds   0.0.0.0:80->80/tcp                  relaxed_blackwell
f6364cff8948   mysql     "docker-entrypoint.s…"   15 hours ago     Up 15 hours     0.0.0.0:3306->3306/tcp, 33060/tcp   ms
$ docker exec -it relaxed_blackwell bash
root@7e87e709164a:/# ls /user/share/nginx/html/
hello.txt  hello1.txt  hello2.txt

◾️ create docker image

$ ls
dockerfile	echo_server.py
$ vi dockerfile
$ vi dockerfile

$ docker build -t echo_test .
[+] Building 32.0s (9/9) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                   0.0s
 => => transferring dockerfile: 141B                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                                                        0.0s
 => [internal] load metadata for docker.io/library/python:3.7                                                                                                                                          3.1s
 => [auth] library/python:pull token for registry-1.docker.io                                                                                                                                          0.0s
 => [internal] load build context                                                                                                                                                                      0.1s
 => => transferring context: 355B                                                                                                                                                                      0.0s
 => [1/3] FROM docker.io/library/python:3.7@sha256:0eabcfa9294fba2214278cc5419ac0f2c59103052400dc4fe5499b66e4c32cf7                                                                                   27.9s
 => => resolve docker.io/library/python:3.7@sha256:0eabcfa9294fba2214278cc5419ac0f2c59103052400dc4fe5499b66e4c32cf7                                                                                    0.0s
 => => sha256:0eabcfa9294fba2214278cc5419ac0f2c59103052400dc4fe5499b66e4c32cf7 1.86kB / 1.86kB                                                                                                         0.0s
 => => sha256:feab2c490a3cea21cc051ff29c33cc9857418edfa1be9966124b18abe1d5ae16 10.00MB / 10.00MB                                                                                                       1.8s
 => => sha256:7edb3502ba150fc2fa848493f85c11ab17bd4cfe44334044810494776dc7c604 2.22kB / 2.22kB                                                                                                         0.0s
 => => sha256:9c9ca311176fba79354694214241446c56c3cfc9fb7ed60d20f1c05892db043f 9.02kB / 9.02kB                                                                                                         0.0s
 => => sha256:7467d1831b6947c294d92ee957902c3cd448b17c5ac2103ca5e79d15afb317c3 7.83MB / 7.83MB                                                                                                         0.8s
 => => sha256:f15a0f46f8c38f4ca7daecf160ba9cdb3ddeafda769e2741e179851cfaa14eec 51.83MB / 51.83MB                                                                                                       7.7s
 => => sha256:937782447ff61abe49fd83ca9e3bdea338c1ae1d53278b2f31eca18ab4366a1e 192.33MB / 192.33MB                                                                                                    15.3s
 => => extracting sha256:7467d1831b6947c294d92ee957902c3cd448b17c5ac2103ca5e79d15afb317c3                                                                                                              0.6s
 => => sha256:e78b7aaaab2cfb7598d50ad36633611a75bff6116d6a0acc2d37df61b5c797be 6.15MB / 6.15MB                                                                                                         3.2s
 => => extracting sha256:feab2c490a3cea21cc051ff29c33cc9857418edfa1be9966124b18abe1d5ae16                                                                                                              0.5s
 => => sha256:d6bffa7c00e33c3b5694e5a1b42fc8fbc1d9ccd079aa9dda0b960fba6b12bdb6 16.33MB / 16.33MB                                                                                                       6.5s
 => => sha256:20e485dc4919e6f109c2c3c66a56fb1ab97a0457c547346f7e72263f3d32511b 233B / 233B                                                                                                             6.8s
 => => sha256:640e66c20a5d31860371be1355ffb6603402b44ad18ce1dd1a749372683f0c38 2.16MB / 2.16MB                                                                                                         7.5s
 => => extracting sha256:f15a0f46f8c38f4ca7daecf160ba9cdb3ddeafda769e2741e179851cfaa14eec                                                                                                              3.9s
 => => extracting sha256:937782447ff61abe49fd83ca9e3bdea338c1ae1d53278b2f31eca18ab4366a1e                                                                                                              9.5s
 => => extracting sha256:e78b7aaaab2cfb7598d50ad36633611a75bff6116d6a0acc2d37df61b5c797be                                                                                                              0.4s
 => => extracting sha256:d6bffa7c00e33c3b5694e5a1b42fc8fbc1d9ccd079aa9dda0b960fba6b12bdb6                                                                                                              0.9s
 => => extracting sha256:20e485dc4919e6f109c2c3c66a56fb1ab97a0457c547346f7e72263f3d32511b                                                                                                              0.0s
 => => extracting sha256:640e66c20a5d31860371be1355ffb6603402b44ad18ce1dd1a749372683f0c38                                                                                                              0.3s
 => [2/3] RUN mkdir /echo                                                                                                                                                                              0.7s
 => [3/3] COPY echo_server.py /echo                                                                                                                                                                    0.0s
 => exporting to image                                                                                                                                                                                 0.0s
 => => exporting layers                                                                                                                                                                                0.0s
 => => writing image sha256:170284b81ba944560d80d503410ed06438f3e027f6c679882cbbce28de9edeee                                                                                                           0.0s
 => => naming to docker.io/library/echo_test                                                                                                                                                           0.0s
$ docker images
REPOSITORY        TAG       IMAGE ID       CREATED         SIZE
echo_test         latest    170284b81ba9   3 minutes ago   877MB

◾️ tag and push docker image

$ docker tag echo_test cit007/echo_test:latest
$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
cit007/echo_test   latest    170284b81ba9   17 minutes ago   877MB
echo_test          latest    170284b81ba9   17 minutes ago   877MB
nginx              latest    35c43ace9216   3 days ago       133MB
jenkins/jenkins    latest    10e33bea4cd2   4 days ago       573MB
mysql              latest    2933adc350f3   12 days ago      546MB

$ docker push cit007/echo_test
Using default tag: latest
The push refers to repository [docker.io/cit007/echo_test]
d384f1036bdc: Pushed
c1c48994302e: Pushed
4d8856180d5f: Mounted from library/python
3676846f14f0: Mounted from library/python
10c7b2ce5f37: Mounted from library/python
e3d73f29c674: Mounted from library/python
10bf86ff9f6a: Mounted from library/python
da654bc8bc80: Mounted from library/python
4ef81dc52d99: Mounted from library/python
909e93c71745: Mounted from library/python
7f03bfe4d6dc: Mounted from library/python
latest: digest: sha256:63c41716facec0c42bbc41a09381aa74040ecae453dc704efb2bee336d8eb4d8 size: 2631

◾️ download create image and run and view history

$ docker images
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$ docker pull cit007/echo_test
Using default tag: latest
latest: Pulling from cit007/echo_test
0ecb575e629c: Already exists
7467d1831b69: Already exists
feab2c490a3c: Already exists
f15a0f46f8c3: Already exists
937782447ff6: Already exists
e78b7aaaab2c: Already exists
d6bffa7c00e3: Already exists
20e485dc4919: Already exists
640e66c20a5d: Already exists
677dfd49d286: Already exists
63f61853d531: Already exists
Digest: sha256:63c41716facec0c42bbc41a09381aa74040ecae453dc704efb2bee336d8eb4d8
Status: Downloaded newer image for cit007/echo_test:latest
docker.io/cit007/echo_test:latest
$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
cit007/echo_test   latest    170284b81ba9   27 minutes ago   877MB
$ docker run -t -p 11111:11111 --name echo --rm cit007/echo_test
server is started
connected by ('172.17.0.1', 60154)
$
$ docker history cit007/echo_test
IMAGE          CREATED          CREATED BY                                      SIZE      COMMENT
170284b81ba9   30 minutes ago   CMD ["python" "/echo/echo_server.py"]           0B        buildkit.dockerfile.v0
<missing>      30 minutes ago   COPY echo_server.py /echo # buildkit            312B      buildkit.dockerfile.v0
<missing>      30 minutes ago   RUN /bin/sh -c mkdir /echo # buildkit           0B        buildkit.dockerfile.v0
<missing>      4 days ago       /bin/sh -c #(nop)  CMD ["python3"]              0B
<missing>      4 days ago       /bin/sh -c set -ex;   wget -O get-pip.py "$P…   8.01MB
<missing>      4 days ago       /bin/sh -c #(nop)  ENV PYTHON_GET_PIP_SHA256…   0B
<missing>      4 days ago       /bin/sh -c #(nop)  ENV PYTHON_GET_PIP_URL=ht…   0B
<missing>      4 days ago       /bin/sh -c #(nop)  ENV PYTHON_PIP_VERSION=21…   0B
<missing>      4 days ago       /bin/sh -c cd /usr/local/bin  && ln -s idle3…   32B
<missing>      4 days ago       /bin/sh -c set -ex   && wget -O python.tar.x…   46.9MB
<missing>      4 days ago       /bin/sh -c #(nop)  ENV PYTHON_VERSION=3.7.10    0B
<missing>      12 days ago      /bin/sh -c #(nop)  ENV GPG_KEY=0D96DF4D4110E…   0B
<missing>      12 days ago      /bin/sh -c apt-get update && apt-get install…   18MB
<missing>      12 days ago      /bin/sh -c #(nop)  ENV LANG=C.UTF-8             0B
<missing>      12 days ago      /bin/sh -c #(nop)  ENV PATH=/usr/local/bin:/…   0B
<missing>      12 days ago      /bin/sh -c set -ex;  apt-get update;  apt-ge…   510MB
<missing>      12 days ago      /bin/sh -c apt-get update && apt-get install…   146MB
<missing>      12 days ago      /bin/sh -c set -ex;  if ! command -v gpg > /…   17.5MB
<missing>      12 days ago      /bin/sh -c set -eux;  apt-get update;  apt-g…   16.5MB
<missing>      12 days ago      /bin/sh -c #(nop)  CMD ["bash"]                 0B
<missing>      12 days ago      /bin/sh -c #(nop) ADD file:8f75f11b2bd2d50e5…   114MB

◾️ private registry (run private registry and push/down image)

$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
cit007/echo_test   latest    170284b81ba9   37 minutes ago   877MB
$ docker run -d -p 5000:5000 --name docker-registry registry
Unable to find image 'registry:latest' locally
latest: Pulling from library/registry
0a6724ff3fcd: Already exists
d550a247d74f: Pull complete
1a938458ca36: Pull complete
acd758c36fc9: Pull complete
9af6d68b484a: Pull complete
Digest: sha256:d5459fcb27aecc752520df4b492b08358a1912fcdfa454f7d2101d4b09991daa
Status: Downloaded newer image for registry:latest
f36b5b717517f87b584457bb2a0346e89c83335165421b2331fc07c58755941a
$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
cit007/echo_test   latest    170284b81ba9   38 minutes ago   877MB
registry           latest    678dfa38fcfa   2 months ago     26.2MB


$ docker tag cit007/echo_test 127.0.0.1:5000/echo_test
$ docker images
REPOSITORY                 TAG       IMAGE ID       CREATED          SIZE
127.0.0.1:5000/echo_test   latest    170284b81ba9   42 minutes ago   877MB
cit007/echo_test           latest    170284b81ba9   42 minutes ago   877MB
registry                   latest    678dfa38fcfa   2 months ago     26.2MB
$ docker push 127.0.0.1:5000/echo_test
Using default tag: latest
The push refers to repository [127.0.0.1:5000/echo_test]
d384f1036bdc: Pushed
c1c48994302e: Pushed
4d8856180d5f: Pushed
3676846f14f0: Pushed
10c7b2ce5f37: Pushed
e3d73f29c674: Pushed
10bf86ff9f6a: Pushed
da654bc8bc80: Pushed
4ef81dc52d99: Pushed
909e93c71745: Pushed
7f03bfe4d6dc: Pushed
latest: digest: sha256:63c41716facec0c42bbc41a09381aa74040ecae453dc704efb2bee336d8eb4d8 size: 2631


$ docker rmi 127.0.0.1:5000/echo_test
Untagged: 127.0.0.1:5000/echo_test:latest
Untagged: 127.0.0.1:5000/echo_test@sha256:63c41716facec0c42bbc41a09381aa74040ecae453dc704efb2bee336d8eb4d8
$ docker images
REPOSITORY         TAG       IMAGE ID       CREATED          SIZE
cit007/echo_test   latest    170284b81ba9   58 minutes ago   877MB
registry           latest    678dfa38fcfa   2 months ago     26.2MB

$ docker pull 127.0.0.1:5000/echo_test
Using default tag: latest
latest: Pulling from echo_test
Digest: sha256:63c41716facec0c42bbc41a09381aa74040ecae453dc704efb2bee336d8eb4d8
Status: Downloaded newer image for 127.0.0.1:5000/echo_test:latest
127.0.0.1:5000/echo_test:latest
$ docker images
REPOSITORY                 TAG       IMAGE ID       CREATED          SIZE
127.0.0.1:5000/echo_test   latest    170284b81ba9   59 minutes ago   877MB
cit007/echo_test           latest    170284b81ba9   59 minutes ago   877MB
registry                   latest    678dfa38fcfa   2 months ago     26.2MB
$

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です