Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

環境

  • 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/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした