0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

dockerの基本コマンド

Last updated at Posted at 2023-05-25

Dockerのインストール

Docker CLIをインストールする。

Dockerコマンド

一連の流れで記載する。

1.Dockerデーモン起動

sudo service docker start

なお、停止は以下のコマンド。

sudo service docker stop

2-1.Dockerfileをビルドしてimageを作成

Dockerfileがあるディレクトリで以下を実行。

docker build -t <ユーザ名>/<名前>:<タグ名> .

2-2.Dockerhubからimageをpull

docker pull <ユーザ名>/<名前>:<タグ名>

3.imageの一覧を表示

imageIDなどを確認するときに使う。

docker image ls

4.imageからcontainerを起動

docker run -it <imageID>

5.containerから抜ける

ctrl + p q

6.containerの一覧を表示する

docker container ls

また稼働中のcontainerのみの表示は以下。

docker ps

7.commitする

docker commit <container名/ID> <ユーザ名>/<名前>:<タグ名>

またここのタグ名は、ローカル上で決めてよい。(ローカル上でのバージョンなど)
タグ付け(下の場合はlatestタグ)は以下のコマンド。

docker tag <imageID> <ユーザ名>/<名前>:latest

補足:image、containerを削除する

docker rmi -f <imageID>

使用していないimage/containerをまとめて削除する。

docker image prune
docker container prune
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?