見出し画像

Container survey partner -docker command edition-

Nice to meet you! My name is Kotaro Nakane, and I work as a director at Definer Inc.

In this article, I will introduce docker commands that are useful when investigating containers.

Our Architecture

Our service is microserviced using docker.
We use CircleCI for CI/CD and deploy automatically several hundred times a month.
In this process, there are often times when we need to investigate the behavior of containers.

Partner for Container Investigation -docker command edition-

(1) As it goes without saying, this command displays a list of containers.

docker ps

The -a option can also be used to display a list that includes stopped containers.

docker ps -a


(2) Displays the log of the container.
This is the command that has been most helpful to me personally.
Standard output and standard error output in the container are displayed as logs.

docker logs [CONTAINER ID/NAMES].

Like the tail command, the -f option can be used to display logs in real time.

docker logs -f [CONTAINER ID/NAMES]

The -t option can be used to display timestamps as well.

docker logs -t [CONTAINER ID/NAMES] -t


(3) Obtain various information about the container.

docker inspect [CONTAINER ID/NAMES].

The above command will display all data in Json format.
For example, if you want to display only the environment variables in a container, you can use the following command.

docker inspect --format='{{range .Config.Env}}{{println .}} {{end}}' [CONTAINER ID/NAMES]'


(4) Enter inside the container.

docker exec -it [CONTAINER ID/NAMES] sh

The first time I executed this command, I was impressed.


or engineers who use docker on a regular basis, this was the basics, and we will make a separate more detailed technical article.
For non-engineers and those who are not familiar with docker, thank you for reading this far despite the geeky content.


For those who have read this

If you have read this far, I am sure we share some values, and I would be very happy if we could talk casually first.
Definer, Inc. is looking for people to work with.

株式会社Definerでは一緒に働く仲間を募集しています

人事・経営・sennryaku
ソフトウェアエンジニア
カジュアル面談です

開発
ソフトウェアエンジニア
フルスタックエンジニア
プロダクトマネージャー(PdM)

ビジネス
人事・経営・sennryaku
ビジネスオープンポジション
インサイドセールス(マネジメント)

その他
カジュアル面談です

この記事が気に入ったらサポートをしてみませんか?