Lab5.2.ImageOperationswithDocker
Lab5.2.ImageOperationswithDocker
2021 1
NAME DESCRIPTION
STARS OFFICIAL AUTOMATED
nginx Official build of Nginx.
15303 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker
con… 2059 [OK]
richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable
of… 815 [OK]
jc21/nginx-proxy-manager Docker container for managing Nginx proxy
ho… 232
linuxserver/nginx An Nginx container, brought to you by
LinuxS… 150
tiangolo/nginx-rtmp Docker image with Nginx using the
nginx-rtmp… 138 [OK]
jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager
131 [OK]
alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from
sou… 105 [OK]
nginxdemos/hello NGINX webserver that serves a simple page
co… 70 [OK]
...
Let’s pull the official nginx image from the Docker Hub:
List images cached in the local repository. The nginx image was just pulled, while the hello-world
image was pulled in a prior lab exercise when we validated the docker installation by running the test
image:
List images and their digests. A digest is a hash associated with the content of each layer part of the
image. Digests ensure each layer’s integrity. The image ID is another hash, derived from the JSON
configuration file of the image. The output has been truncated for readability:
sha256:8f335768880da6baf72b70c701002b45f4932acae8d574dedfddaf967fc3ac90
Push an image to Docker Hub. Assuming the existence of an lfstudent account on Docker Hub, a user
can login from the CLI and then push an image into the registry to be shared with other users. The
following commands are provided only for illustrational purposes:
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: lfstudent
Password: ********
Login Succeeded
Let’s pull another image from Docker Hub, the official alpine image, and tag it:
NAME DESCRIPTION
STARS OFFICIAL AUTOMATED
alpine A minimal Docker image based on Alpine
Linux… 7748 [OK]
mhart/alpine-node Minimal Node.js built on Alpine Linux
483
anapsix/alpine-java Oracle Java 8 (and 7) with GLIBC 2.28
over A… 472 [OK]
...
If we examine closely the output, we notice that the tag command generated another image entry
myalps:v1, referencing the same image ID as the original alpine:latest image. Both the image ID
and size values are identical.
Let’s display the alpine image details. Between the image ID and its digest, we find both the alpine
and myalps tags. Try running the inspect command with the myalps:v1 image and compare the two
outputs:
[
{
"Id":
"sha256:021b3423115ff662225e83d7e2606475217de7b55fde83ce3447a54019a77aa2",
"RepoTags": [
"alpine:latest",
"myalps:v1"
],
"RepoDigests": [
"alpine@sha256:eb3e4e175ba6d212ba1d6e04fc0782916c08e1c9d7b45892e9796141b1d379a
e"
],
"Parent": "",
"Comment": "",
"Created": "2021-08-06T17:19:45.183996158Z",
"Container":
"72bdff81d8bf6dfb5d83e6cbdd59564e419e3a97931ce4e31dd3f215eae4914c",
"ContainerConfig": {
"Hostname": "72bdff81d8bf",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/sh\"]"
],
"Image":
"sha256:dc0d5c673ee2846463a00ec42d78344d3d5f37ac23c0723da4cd0051c16f4ef4",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"DockerVersion": "20.10.7",
"Author": "",
"Config": {
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/sh"
],
"Image":
"sha256:dc0d5c673ee2846463a00ec42d78344d3d5f37ac23c0723da4cd0051c16f4ef4",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": null
},
"Architecture": "amd64",
"Os": "linux",
"Size": 5595292,
"VirtualSize": 5595292,
"GraphDriver": {
"Data": {
"MergedDir":
"/var/lib/docker/overlay2/6bbabbf0f44c4f7955180c54680093f02d67da20463d903e5981
96b6cc35503b/merged",
"UpperDir":
"/var/lib/docker/overlay2/6bbabbf0f44c4f7955180c54680093f02d67da20463d903e5981
96b6cc35503b/diff",
"WorkDir":
"/var/lib/docker/overlay2/6bbabbf0f44c4f7955180c54680093f02d67da20463d903e5981
96b6cc35503b/work"
},
"Name": "overlay2"
},
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:bc276c40b172b1c5467277d36db5308a203a48262d5f278766cf083947d05466"
]
},
"Metadata": {
"LastTagTime": "2021-08-12T20:34:52.630348089Z"
}
}
]
Let’s remove a cached image from the local repository (using the --force option), then list available
images with images this time instead of image ls:
Untagged: alpine:latest
Untagged:
alpine@sha256:eb3e4e175ba6d212ba1d6e04fc0782916c08e1c9d7b45892e9796141b1d379ae