Uninstall docker and re-install specific version by using apt-get command.

【前提】
Dockerで作業をしようとしたら、以下のエラーが出てきてしまったので、Dockerのバージョンを下げることにしました。


vagrant$
vagrant$sudo docker build -t xxxxxx/cloudperf . 
Sending build context to Docker daemon  12.8 kB
Error response from daemon: client is newer than server (client API version: 1.24, server API version: 1.23)
vagrant$

1. 削除


vagrant$
vagrant$sudo apt-get --purge remove docker.io
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  bridge-utils containerd dns-root-data dnsmasq-base libb64-0d libcurl3 libjsoncpp1 libluajit-5.1-2 libluajit-5.1-common
  libnetfilter-conntrack3 libpcp-gui2 libpcp-pmda-perl libpcp-pmda3 libpcp-trace2 libpcp3 pcp-conf python-pcp runc sysdig-dkms ubuntu-fan
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  docker.io*
+ rm -rf /var/lib/docker
dpkg: warning: while removing docker.io, directory '/etc/docker' not empty so not removed
Processing triggers for man-db (2.7.5-1) ...
vagrant$ls /etc/docker/
key.json
vagrant$more /etc/docker/key.json 
more: cannot open /etc/docker/key.json: Permission denied
vagrant$sudo more /etc/docker/key.json 
{
    "crv": "P-256",
    "d": "d60VFOsjaeYwjrRBOIAngRnh7m6-25U8uqhW9zv1Jy8",
    "kid": "JPQO:IZZY:RQNS:YCRN:3LGW:IXCV:4LH5:QLXC:SIOL:5WGW:HPWK:3MBA",
    "kty": "EC",
    "x": "xqdUeVHQES-XhDpYyRhmeRuWv8A2cdmfaGgkOzlivsw",
    "y": "n9e7FCF4QoMfJ5YzljaD0IXles2_RmFQMbTohUGEM9w"
}
vagrant$

2. 念のため設定ファイルも削除


vagrant$
vagrant$sudo rm -ri /etc/docker/ 
rm: descend into directory '/etc/docker/'? y
rm: remove regular file '/etc/docker/key.json'? y
rm: remove directory '/etc/docker/'? y
vagrant$

3. インストール可能なバージョンを確認する。


vagrant$
vagrant$sudo apt-cache policy docker.io
docker.io:
  Installed: (none)
  Candidate: 1.12.1-0ubuntu13~16.04.1
  Version table:
     1.12.1-0ubuntu13~16.04.1 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages
     1.10.3-0ubuntu6 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
vagrant$

4. バージョンを指定してインストール


vagrant$
vagrant$sudo apt-get install docker.io=1.10.3-0ubuntu6
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  containerd libb64-0d libcurl3 libjsoncpp1 libluajit-5.1-2 libluajit-5.1-common libpcp-gui2 libpcp-pmda-perl libpcp-pmda3 libpcp-trace2 libpcp3
  pcp-conf python-pcp runc sysdig-dkms
Use 'sudo apt autoremove' to remove them.
Suggested packages:
vagrant$

5. インストールされたバージョンの確認


vagrant$
vagrant$dpkg -l |grep docker.io
ii  docker.io                            1.10.3-0ubuntu6                          amd64        Linux container runtime
vagrant$
vagrant$docker --version
Docker version 1.10.3, build 20f81dd
vagrant$

Thank you !:laughing:

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.