35

I'm running centos 7 and have installed docker on host using epel packages:

yum install epel-release
yum install docker

But the docker version is-Docker version 0.11.1-dev, build 02d20af/0.11.1

The latest stable branch of docker is 1.2

I'm running couple of containers on this host, so how can i update docker safely on this host?

yum update docker does not update to the latest version as the epel repo has old package.

nmd
  • 823
  • 1
  • 7
  • 17
  • Here is another answer on how to install Docker 1.5 on CentOS 7: http://stackoverflow.com/questions/28961080/how-to-install-the-latest-version-of-docker-on-centos-7 – Be Kind To New Users Mar 24 '15 at 16:13

4 Answers4

47

Update to upgrade docker CentOS 7.4

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux  docker-engine-selinux docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce


sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker

Refer:

https://docs.docker.com/install/linux/docker-ce/centos/

koxt
  • 683
  • 7
  • 16
rmsys
  • 931
  • 13
  • 18
  • 2
    Do not use this instruction if you are unsure. You can lose docker having error on `yum install docker-ce` step: Package: docker-ce-18.06.0.ce-3.el7.x86_64 (docker-ce-stable) Requires: container-selinux >= 2.9 – SerG Jul 31 '18 at 15:29
  • This was the command I just ran and it seems to have worked: `yum update docker-ce docker-ce-cli containerd.io` – CPAR Feb 04 '20 at 17:29
  • 1
    this worked for me and the accepted answer did not – Chagai Friedlander Dec 03 '20 at 11:30
40

Note that current stable version of Docker is actually 1.3, not 1.2. See the Docker CHANGELOG to discover the latest version.

Before upgrading your docker host, you might want to backup some of the docker images you have, especially those issued from the docker commit command. To do so, take a look at the docker export command. You might also want to backup your containers' volumes. For that take a look at the Docker user guide on data volumes.

Once you are confident you have all the backups you need for an eventual fresh start you can move on upgrading your Docker daemon.

On the Docker installation guide for CentOS 7, it is advised to install docker from the binaries if you want the latest. I suggest you follow those instructions to install the latest docker. Docker now provides updates through the yum package manager.

Once done with that use the docker images command to verify if you still have your Docker images and docker ps to check your containers. If some are missing, recreate them from your backups.

If you created docker images from custom Dockerfiles, you also want to rebuild those images to check that no Dockerfile has issues with the new Docker daemon. There is a big gap between Docker 0.11.1 and 1.3 and fixes and new features were brought to the Dockerfiles syntax.


In details here are the commands to run once you are ready to upgrade docker:

# stop the docker service
$ sudo service docker stop

# download the latest docker binary and replace the current outdated docker
# DEPRECATED WAY TO UPGRADE DOCKER: $ sudo wget https://get.docker.com/builds/Linux/x86_64/docker-latest -O /usr/bin/docker
$ sudo yum update docker-engine

# start the docker service
$ sudo service docker start

# check the version
$ sudo docker version

# check the images and containers
$ sudo docker images
$ sudo docker ps
$ sudo docker ps -a
joedragons
  • 2,505
  • 21
  • 21
Thomasleveil
  • 95,867
  • 15
  • 119
  • 113
  • If I uninstall docker (the one installed through yum) will the images still be there are will they be purged? – nmd Oct 21 '14 at 15:43
  • 2
    I was able to upgrade docker on CentOS 7 without loosing the images or containers. I edited my answer with the commands I used to upgrade docker. Note that you still need to have backups just in case you have difficulties. – Thomasleveil Oct 22 '14 at 07:52
  • 1
    **Warning!!** This answer destroys Docker on CentOS! The latest file is a 404 Error! Don't use it! – user6253329 Apr 25 '16 at 20:43
  • 1
    Thank you for the heads up! I edited my answer so that the upgrade is now done using `yum` – Thomasleveil Apr 26 '16 at 13:11
  • i agree with you.. this is already destroy docker on my server. – nur zazin Feb 28 '20 at 13:16
  • @thomasleveil please check this https://stackoverflow.com/questions/67942974/centos-8-how-to-update-docker-client –  Jun 13 '21 at 19:26
  • this command is not recognized. this works. – Alexey Burnakov Jun 02 '22 at 07:00
8

try these commands:

sudo yum update -y

stop docker before upgrade

sudo service docker stop
sudo yum upgrade docker*

start it again

sudo service docker start

check the version

sudo docker version
Ehsan
  • 3,711
  • 27
  • 30
0

You can install docker using repo or a package file as below:

yum install -y yum-utils

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 and accept the GPG key if requested to do so.

For the installation of a particular version, you can refer tothe command below :

yum list docker-ce --showduplicates | sort -r

So you may use the command above with the installation instruction for the docker upgradation process.

OR

Installation steps using the package download Visit this link: https://download.docker.com/linux/centos Then select your preferred CentOS version. Once you've found the.rpm file for the Docker version you wish to instal, navigate to x86 64/stable/Packages/. So to upgrade the docker using package downloading instead of repository add, you can use yum -y upgrade and point it to the new file.

helvete
  • 2,455
  • 13
  • 33
  • 37