Docker

Pluralsight: Docker Deep Dive

Overview

Problem of Hypervisor/Virtual Machine: need to deal with many host OS, admin overhead (patching, upgrade, security etc) stuff.

Container: more lightweight and fast to start/stop.

Container Registries: for container images. https://hub.docker.com/explore/

REGISTRY/REPO : IMAGE(TAG)

docker.io(default) / <repo> : latest (default)

So, an example command will be: docker image pull redis

*best practice is not to use latest (specify the actual version number) in production as the latest could be pointed to any version and changed, could break your app.

Containerizing an App

Build by Dockerfile with a Tag

sudo docker build -t tomcat-fortress .

Run an Image

sudo docker run -d -p 8080:8080 tomcat-fortress

Working with Container

List all containers (only IDs)

docker ps -aq

Stop all running containers

docker stop $(docker ps -aq)

Remove all containers

docker rm $(docker ps -aq)

Remove all images

docker rmi $(docker images -q)

Attach local standard input, output, and error streams to a running container

$ sudo docker attach 665b4a1e17b6 #by ID
or
$ sudo docker attach loving_heisenberg #by Name
$ root@665b4a1e17b6:/#

Purging All Unused or Dangling Images, Containers, Volumes, and Networks

Docker provides a single command that will clean up any resources — images, containers, volumes, and networks — that are dangling (not associated with a container):

docker system prune

To additionally remove any stopped containers and all unused images (not just dangling images), add the-aflag to the command:

docker system prune -a

results matching ""

    No results matching ""