[Summary of technical books] Summary of reading "Introduction to Docker / Kubernetes Practical Container Development"

Chapter 1 Docker Basics

--You can create an environment with just a configuration file and commands. --Deployment that includes application and execution environment is Docker style --Advantages of using Docker --Environmental troubles can be minimized --Idempotence can be maintained --The same result is guaranteed no matter how many times you execute it.

Chapter 2 Deploying Docker Containers

--What is a Docker image? --Templates for embodying containers

$ docker image pull gihyodocker/echo:latest #Get the image

$ docker container run -t -p 9000:8080 #Container execution

$ curl http://localhost:9000/ #Try to access

$ docker stop $(docker container ls -q) #Stop
$ docker container stop $(docker container ls --filter "ancestor=example/echo" -q) #Stop

$ docker image build -t example/echo:latest . #Create docker image

$ docker image ls #Check docker image

$ docker container run -p 9000:8080 example/echo:latest #Port forwarding

--Operations for Docker --It can be roughly divided into two types: images and containers.

Docker image

--"Build a Docker image"

$ docker image --help #See help

$ docker search --limit 5 mysql #Search for

--imaegeID also serves as a version number --latest is the master branch of Git

$ docker image tag example/echo:latest example/echo:0.1.0 #Tag a specific point with a version name, etc.

Docker container

--Three states of execute, stop, and discard

$ docker container run -t -d --name gihyo-echo example/echo:latest #Create a named container (useful during development)
$ docker container run -it alpine:latest #A terminal is displayed and you can enter characters. You can use it as if you logged in to a virtual environment.

$ docker container ls -q #Extract only the container ID
$ docker container ls --filter "name=echo1" #Filter by name
$ docker container ls -a #Include finished container

$ docker container rm f66f6f2013da #Destroy the container
$ echo '{"version":100}' | docker container run -i --rm gihyodocker/jq:1.5 '.version' #The container you need only then--Immediately destroy with rm

$ docker container logs -f &(docker container ls --filter "ancestor=jenkins" -q) #View log

$ $ docker container exec -it echo sh #Execute command in container

$ docker container cp echo:/echo/main.go . #Copy what's in the container
$ docker container cp dummy.txt echo:/tmp #Copy to container

Commands for operation management

$ docker container prune #Bulk delete containers that are not running
$ docker image prune #Bulk delete images that are not running

$ docker container stats #View resource usage on a container-by-container basis

docker-compose.yml


version: "3"
services:
  echo:
    image: example/echo:latest
    ports:
      - 9000:8080

$ docker-compose up -d #Start-up
$ docker-compose down #Stop
$ docker-compose up -d --build #Build every time and start behind the scenes
$ docker-compose ps #Confirm startup

--Share volume, not copy

Chapter 3 Building and Deploying Practical Containers

――Docker is a container-based separation of application and infrastructure. --One concern for one container --"Hello! Is output every 1 minute" etc. --Are there any side effects when duplicated as a replica? --Docker's portability limits --CPU architecture and OS assumptions --Dynamic link issues --Control the behavior of the application with environment variables

Chapter 4 Practical application construction

Create a TODO app with Swarm

$ docker container run -v ${PWD}:/root ch04/tododb:latest

So far for the time being.

Recommended Posts

[Summary of technical books] Summary of reading "Introduction to Docker / Kubernetes Practical Container Development"
Introduction to Docker / Kubernetes Practical Container Development
[Summary of technical books] Summary of reading "Learn Docker from the basics"
[Docker] Introduction to docker compose Basic summary of docker-compose.yml
Introduction to Linux Container / Docker (Part 1)
Introduction to Linux Container / Docker (Part 2)
Introduction of Docker --Part 1--
Introduction to Practical Programming
Introduction to Keycloak development
[Docker] Introduction of basic Docker Instruction
Introduction to RSpec-Everyday Rails Summary-
End of Docker and Kubernetes: Grace period from SIGTERM to SIGKILL
Summary of Docker understanding by beginners ⑥ ~ Until automatic deployment of docker container to EC2 instance using CodeDeploy and CodePipeline ~