4
4

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 5 years have passed since last update.

CentOS 7.2 に docker をインストールする手順

4
Posted at

環境

  • OSX の VirtualBox 上のゲスト
  • CentOS 7.2

手順

yum レポジトリの設定。/etc/yum.repo.d/docker.repo を作成し、以下を記載する。

/etc/yum.repo.d/docker.repo
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

docker engine を yum でインストール

# yum install docker-engine

docker サービスを start する。

# systemctl start docker

ちなみに、再起動後も docker サービスが立ち上がるようにするには、以下で docker サービスを有効にしておく。

# systemctl enable docker

docker run hello-world を実施して、docker が無事に動いていることを確認。以下が出力されたら docker が動作して、hello-world コンテナが作成されている。

# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b901d36b6f2f: Pull complete 
0a6ba66e537a: Pull complete 
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

# 

hello-world コンテナはもういらないので、削除する。

hello-world コンテナの CONTAINER ID を docker ps -a で確認。以下は CONTAINER ID が c5414be974b8。

# docker ps -a
CONTAINER ID        IMAGE                  COMMAND               CREATED             STATUS                         PORTS                    NAMES

c5414be974b8        hello-world            "/hello"              About an hour ago   Exited (0) About an hour ago                            angry_brahmagupta
# 

docker rm で CONTAINER ID c5414be974b8 の hello-world コンテナを削除。

# docker rm c5414be974b8
c5414be974b8
# 

hello-world コンテナが削除されていることを確認。

# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
# 

参考資料
https://docs.docker.com/engine/installation/centos/

4
4
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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?