Docker の紹介
Tim Sangster
Software Engineer @ DataCamp
| コマンド | 使用方法 |
|---|---|
| nano <file-name> | nano テキストエディタで <file-name> を開く |
| touch <file-name> | 指定した名前の空のファイルを作成します |
| echo "<text>" | <text>をコンソールに表示 |
| <command> >> <file> | <command> の出力を <file> の末尾にプッシュします |
| <command> -y | すべてのプロンプトに自動的に「はい」と応答する <command> |
docker から始まります。
docker run <image-name>
docker run hello-world
Hello from Docker!
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon created a new container from the hello-world image which runs
the executable that produces the output you are currently reading.
3. The Docker daemon streamed that output to the Docker client, which sent it to
your terminal.
docker run <image-name>
docker run ubuntu
repl@host:/# docker run ubuntu
repl@host:/#
-it を docker run に追加すると、起動したコンテナーで対話型シェルが得られます。
docker run -it <image-name>
docker run -it ubuntu
docker run -it ubuntu
repl@container:/#
repl@container:/# exit
exit
repl@host:/#
-d を docker run に追加すると、コンテナーがバックグラウンドで実行され、シェルの制御を取り戻せます。
docker run -d <image-name>
docker run -d postgres
repl@host:/# docker run -d postgres
4957362b5fb7019b56470a99f52218e698b85775af31da01958bab198a32b072
repl@host:/#
docker ps
repl@host:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED
4957362b5fb7 postgres "docker-entrypoint.s…" About a minute ago
STATUS PORTS NAMES
Up About a minute 5432/tcp awesome_curie
docker stop <container-id>
repl@host:/# docker stop cf91547fd657
cf91547fd657
| 使用方法 | コマンド |
|---|---|
| コンテナを起動 | docker run <image-name> |
| インタラクティブコンテナーを起動 | docker run -it <image-name> |
| 切り離されたコンテナーを起動する | docker run -d <image-name> |
| 実行中のコンテナを一覧表示 | docker ps |
| コンテナを停止する | docker stop <container-id> |
Docker の紹介