Wednesday, January 1, 2020

Docker Commands

>docker ps
     list running containers (processes inside of docker) (docker status) (list of running apps)

>docker start/stop [first 3 chars of id, or all of it] or [name]

>docker run hello-world
    I didn't download it, but it automatically downloads it and starts it

>docker run -p 8081:80 nginx
    downloads and runs this web server on localhost:8081

>docker run -p 4000:4000 docs/docker.github.io
     gives you a local docs at localhost:4000, same as http://docs.docker.com/

>docker run -p 4000:4000 -it --name docs docs/docker.github.io
    --it is for interactive terminal which makes your command prompt able to kill the process (docker stop) when pressing ctrl-c.

>docker ps -a
     view all installed containers and their run status

>docker images
     view all downloaded images

View containers that are stopped (not visible using ps command):
>docker container ls -a

Use CLI window to view files in a running container:
>docker exec -it [container name] cmd
     this will give you a cmd prompt at root of the application in the container's file system

Save an image. I had created and started a container using VS 2019 just by adding docker support (right click on web project in solution explorer, Add/Docker support). It showed up in >docker ps and in >docker images. You can also use >docker container ls -a and you don't necessarily need the image id, you can use the ps and use the human readable value under the IMAGE column.
>docker save -o C:\Dev\Learning\Docker\CoreWebHelloWorld\image.tar 291a865d3b8a
     you have to use the image id, not container id, so go to >docker images to get the image id.


>docker load -i C:\Dev\Learning\Docker\CoreWebHelloWorld\image2.tar

Remove container.
>docker container rm [container id]

Docker Fundamentals

A docker image is a pre-packaged application or VM template.

Docker, the technology in 2 sentences:
    Container - like fast, lightweight virtual machines
    Docker - makes running apps inside containers easy

An image is like a stopped container or a template on how to build a container.

Workflow:
Write code > build > create (build) docker image > push to registry > start a container from the image and your app is now running.

You want to build your apps to avoid the "monolith" architecture. Modules within the app should be "microservices" or simply put, the app module pulled out of the monolith and placed into its own application architecture whether its a web service or console app and put into a container. That way if you want to update just step 4 of the Claim Payments orchestrator, we just have to deploy that one container and not anything else.

https://hub.docker.com/ - registry

Kubernetes
Orchestrates docker containers and nodes (like a load balancer for one of its many features)

Docker Desktop
Install:
https://hub.docker.com/?overlay=onboarding
Guide:
https://docs.docker.com/docker-for-windows/install/


Docker's Modernizing Traditional Apps program, put legacy apps into containers.
https://goto.docker.com/rs/929-FJL-178/images/SB_MTA_04.14.2017.pdf