3
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.

Docker 1.12 へのアップデート(CentOS7)

Last updated at Posted at 2016-08-18

docker を yum で更新したらちょっとてこずった。

インストール後の環境としては下記のとおり。

# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

# yum list installed | grep docker
docker-engine.x86_64                  1.12.0-1.el7.centos            @dockerrepo
docker-engine-selinux.noarch          1.12.0-1.el7.centos            @dockerrepo

docker 1.12.0 へ更新してサーバ再起動すると下記のエラーが出て docker が起動しなくなってしまった。

Failed to start docker.service: Unit docker.socket failed to load: No such file or directory.

no sockets found via socket activation: make sure the service was started by systemd

"docker daemon -H fd://" fails with message "No sockets found" under Ubuntu 15.10 #22847
↑ここらへんのやりとり見て、 -H fd:// を削除してみてもうまくいかない。

修正後のユニットファイル
[Service]
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
ExecStart=
ExecStart=/usr/bin/docker daemon $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY


しかし、また別のエラーが出る。
docker.service lacks both ExecStart= and ExecStop= setting. Refusing.

ユニットファイルの書き方がおかしいのか?

リリースページをみると、 docker v1.12.1-rc2 が公開されていて、解決策ものっていた。

下記の解決策をやってみた。
Backup the current version of the unit file, and replace the file with the version that ships with docker 1.12

既存ファイル:/etc/systemd/system/docker.service.d/docker.conf をバックアップ。

https://raw.githubusercontent.com/docker/docker/v1.12.0/contrib/init/systemd/docker.service.rpm の内容で上書きするが、
今度は別のエラーメッセージが出た。

docker.service has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.

今までの設定ファイルをみると ExecStart= という行があったのでその一行を追加することで無事 docker が起動した。

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart= ←追加
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

##8/23 追記1:/etc/sysconfig/docker が効かない
OPTIONS で REMOTE API を有効化していたが、ps -ef で dockerd をみてみるとどうやらオプションがわたってない。
ユニットファイルを置き換える前のものを参考にして下記のように修正したらうまくいった。

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=-/etc/sysconfig/docker ※追加
EnvironmentFile=-/etc/sysconfig/docker-storage ※追加
EnvironmentFile=-/etc/sysconfig/docker-network ※追加
ExecStart=
ExecStart=/usr/bin/dockerd $OPTIONS \ ※追加
          $DOCKER_STORAGE_OPTIONS \ ※追加
          $DOCKER_NETWORK_OPTIONS \ ※追加
          $BLOCK_REGISTRY \ ※追加
          $INSECURE_REGISTRY ※追加
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target
3
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
3
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?