LoginSignup
6
4

More than 5 years have passed since last update.

CentOS7にdocker-engineインストール&Proxy環境での設定

Last updated at Posted at 2017-07-05

はじめに

CentOSにdockerをインストールしたときに普通にsudo yum install docker
とやるとsystemctl startしたときにデーモンが立ち上がらなかったので
yumリポジトリを作ってインストール先を変えてyum installした。

dockerのアンインストール

yum list installed | grep docker
これでインストールしているdocker関連のものを検索
sudo yum -y remove パッケージ名
でとりあえずすべてアンインストール

既存のyumパッケージの更新

sudo yum update

yumリポジトリの追加

sudo vi /etc/yum.repos.d/docker.repoを実行してyumリポジトリを作成
そして以下の内容を記述

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

baseurlはリポジトリのパスを指定している。
enabledはリポジトリを有効にしている。
gbgcheackは1で有効にしている。
gbgkeyはgbgを確認するためのカギの場所を指定している。
gbgチェックとは、リポジトリの信用性をチェックする物である。

yum install

ここでsudo yum install docker-engineを実行。
ここはすんなり。

proxy設定

/etc/systemd/system/docker.service.d/http-proxy.confを新規作成して
以下の内容を記述。

[Service]
Environment="HTTP_PROXY=http://プロキシ名:ポート番号/"

これでsystemctlを実行するこのファイルを参照してくれ、proxyの設定ができます。
その後デーモンのリロードsytemctl daemon-reloadを実行

systemctl start docker

sudo systemctl start dockerを実行
sudo docker run hello-worldを実行して

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 ID:
 https://cloud.docker.com/

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

と出力があればOK!!!
そしたらsudo systemctl enable docker
sudo systemctl restart dockerをして完了

おわりに

デフォルトのyum install dockerでうまく起動できない人はこの方法でやってみて下さい。
僕もエラーで半日くらい時間をとられました。
Let's docker run !!

参考文献

6
4
2

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