Containers
-
Login to the Docker registry docker-stage.liatr.io
Solution
docker login docker-stage.liatr.io
Example Output:
[user12@VM:dojo-sandbox ~]$ docker login docker-stage.liatr.io Username: user12 Password: ************* Login Succeeded
-
Pull down the nodejs image from docker-stage.liatr.io found at /repo/nodejs10 with tag 1.0.0
Solution
docker pull docker-stage.liatr.io/repo/nodejs10:1.0.0
Example Output:
[user12@VM:dojo-sandbox ~]$ docker pull docker-stage.liatr.io/repo/nodejs10:1.0.0 Trying to pull repository docker-stage.liatr.io/repo/nodejs10 ... 1.0.0: Pulling from docker-stage.liatr.io/repo/nodejs10 d69140bdce18: Pull complete a82dd37af30d: Pull complete bf4a6f4593f2: Pull complete f8c91665e5ce: Pull complete 95d1c15ed2d1: Pull complete fe908ec87177: Pull complete dc37faa77625: Pull complete 08c6e439e8ee: Pull complete b2475b29510d: Pull complete 796ad60e2332: Pull complete cb86202e581e: Pull complete f30d62cd2e8b: Pull complete Digest: sha256:6bc3a2922cdd82b75b2f2f34e47aef08ad49031024f64e7e8625c706d1ac0c74 Status: Downloaded newer image for docker-stage.liatr.io/repo/nodejs10:1.0.0
If you notice the number of 'pulls' it completed, it completed 12 of them. Why is that? That's because it pulls down each layer individually. There are 12 layers to this nodejs image.
-
Try to run the nodejs image you just pulled down. Then list all running and exited containers.
Solution
docker run docker-stage.liatr.io/repo/nodejs10:1.0.0
docker ps -a
Example Output
[user12@VM:dojo-sandbox ~]$ docker run docker-stage.liatr.io/repo/nodejs10:1.0.0 [user12@VM:dojo-sandbox ~]$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3d1bfd34cb32 docker-stage.liatr.io/repo/nodejs10:1.0.0 "/bin/bash" 4 seconds ago Exited (0) 3 seconds ago hungry_joliet
You'll notice that the command exited after 3 seconds. Why? Because there was no executable command inside the container. It started, had nothing to do, so it shut down.
-
Try running the image again with the -i and -t options telling it to run a /bin/bash command. If you are successful you should find yourself inside the running container. Take a look inside if you'd like. Run
exit
to escape from the container.Solution
[user12@VM:dojo-sandbox ~]$ docker run -i -t docker-stage.liatr.io/repo/nodejs10:1.0.0 /bin/bash [jnpr@7d43450ee7c8 /]$ pwd / [jnpr@7d43450ee7c8 /]$ ls bin boot dev etc home lib lib64 media mnt node_modules opt proc root run sbin srv sys tmp usr var [jnpr@7d43450ee7c8 /]$ exit exit [user12@VM:dojo-sandbox ~]$
-
Clear Docker containers and Docker images
Clean up any Docker containers that are not running and all Docker images not associated with a running container
Solution
docker rm $(docker ps -a -q)
Example Output:docker image prune -a
[user12@VM:dojo-sandbox ~]$ docker rm $(docker ps -a -q) 7d43450ee7c8 3d1bfd34cb32 [user12@VM:dojo-sandbox ~]$ docker image prune -a WARNING! This will remove all images without at least one container associated to them. Are you sure you want to continue? [y/N] y Deleted Images: untagged: docker-stage.liatr.io/repo/nodejs10:1.0.0 untagged: docker-stage.liatr.io/repo/nodejs10@sha256:6bc3a2922cdd82b75b2f2f34e47aef08ad49031024f64e7e8625c706d1ac0c74 deleted: sha256:78bff9d1a474cf1b931c5c4c948a4998463e4c1bb28de6224673287c8baa6d62 deleted: sha256:60030f89badfaf2467928c2ce5d1a0e3a5cb3df669352cd4f92334eb7bbe82a4 deleted: sha256:ccb55c3c59a69d4b6474c02d4d77b9177789c87ac48cd3178433d16bf12f2fae deleted: sha256:4f0407d9ddbc8c96d1464a0d5f3bfd6ad7976ca91368281b5a155742a1a18c01 deleted: sha256:f50464cb3b027c2b21ab88fed1024b5912e9cdb745fc2524966db6f0cb53f807 deleted: sha256:062f2c15b6c1c30aa2762be4526dd21edf7e989585925a31f20a9a7953a5d112 deleted: sha256:0535d3c162a39caf2a9e99dfc8af34f9f0c62ebd01af95ab9a4b8d84b177d12c deleted: sha256:be919eed8b21a340b1cbd7c84470ba3f2e8220fa13f518aab6f541f7924e7f8c deleted: sha256:1a909fa3db3f667c5784c200735c2858ac84523b566c6f4077f603bd4fb83723 deleted: sha256:9afeae4d34d0369cbc5695e3c185e224040bd2c6c068d78a68a76b413444cfa1 deleted: sha256:2467b4f9cb944fe1c0ea60d1d1a450af6922a349da84ea13e5ef2794e366a47c deleted: sha256:d8298763f7d9aed4cfb2e38a964b9ec8358d9ff3c67b6539bc468fd3c1dd701a deleted: sha256:03b8aa00f0018b0d0eb70a535c71c87da3bd7810bc7d5fb1ec5237b7aaf0a0cb Total reclaimed space: 1.01 GB [user12@VM:dojo-sandbox ~]$