I will write what I learned about docker anyway (second)

Last time

Write what you learned about docker anyway \ (1st ) -Qiita

next time

Reference books

Docker/Introduction to Kubernetes Practical Container Development|Akinori Yamada|Computer / IT|Kindle Store| Amazon

Build image

command

docker image build -t image name[:Tag name]Dockerfile location directory path

-f option

--The docker image build command goes to find the Dockerfile by default --But if you want to use a Dockerfile with a different name, use the -f option. --For example, if you use a Dockerfile named Dockerfile-test, it will be as follows.

docker image build -f Dockerfile-test -t example/echo:latest

Search for images

command

Use the docker search command to search the repository registered in the Docker Hub registry.

docker search [options]Search keyword

--limit [display count]

Use the --limit option to limit the number of items displayed by the search command.

$ docker search --limit 5 mysql
NAME                  DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                 MySQL is a widely used, open-source relation…   10014               [OK]                
mysql/mysql-server    Optimized MySQL Server Docker images. Create…   733                                     [OK]
mysql/mysql-cluster   Experimental MySQL Cluster Docker images. Cr…   76                                      
bitnami/mysql         Bitnami MySQL Docker Image                      45                                      [OK]
circleci/mysql        MySQL is a widely used, open-source relation…   19                                  

Image tagging

Tagging images

Docker image tags are used to help identify Docker images with a particular image ID --Image ID = Docker image version

Tag the latest specific point with the version name etc. so that you can get the specific version of docker image at any time.

docker image tag Original image name[:tag]New image name[:tag]

Example: tag example / echo latest with 0.1.0

docker image tag example/echo:latest example/echo:0.1.0

(output)

$ docker image ls

REPOSITORY                                    TAG                 IMAGE ID            CREATED             SIZE
example/echo                                  latest              4bc94bb3c1af        3 days ago          750MB
example/echo                                  0.1.0               4bc94bb3c1af        3 days ago          750MB

Working with Docker containers

docker container restart Restart the container

docker container restart container ID or container name

docker container rm Dispose of container

docker container rm container ID or container name

copy docker container cp file

Inside the container → host

docker container cp [options]Container ID or container name:Copy source in container Copy destination of host

Host → Inside the container

docker container cp [options]Host copy source container ID or container name:Copy in container-Ahead

Commands for operation management

prune destroyed

--docker container prune can delete all containers that are not running. --Many of the containers that are actually stopped are often unnecessary, so it is better to delete them regularly.

docker container prune [option]

When you want to delete images at once

docker image prune [option]

Delete all unused Docker containers, images, volumes, networks, etc. at once

docker system prune [option]

Recommended Posts

I will write what I learned about docker anyway (second)
I will write what I learned about docker anyway (first)
What I learned about Kotlin
What i learned
Summary of what I learned about Spring Boot
What I learned ② ~ Mock ~
What I learned ① ~ DJUnit ~
What I researched about Java 8
What I researched about Java 6
What you learned about hashes
What I researched about Java 9
What you learned about symbols
What I researched about Java 7
What I researched about Java 5
What I learned with Java Gold
What I learned with Java Silver
What I researched about Java learning
Take what you've learned about Java reflection
What I learned through the swift teacher
What is Docker? I tried to summarize
What I learned from Java monetary calculation
About Docker
About Docker
[Personal memo] I learned a little about modifiers
[Rails] I learned about database data type types!
What I learned in Java (Part 2) What are variables?
Summary of what I learned in Spring Batch