はじめに
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 !!
参考文献
- CentOS — Docker-docs-ja 1.13.RC ドキュメント
- 先輩のリファレンス