fixyourserver.com

A lot of stuff and things…

Upgrading from CentOS-Extras docker to Docker Community Edition

Recently I ran into an issue where I wanted to move from CentOS’ docker RPM from their Extras repository to Docker’s Community Edition. I ran into some issues on my first go and lost a couple of containers along the way. The CentOS package includes defined defaults in the service/systemd file. Example:

ExecStart=/usr/bin/dockerd-current \
–add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
–default-runtime=docker-runc \
–exec-opt native.cgroupdriver=systemd \
–userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY\
$REGISTRIES

When upgrading between the two, things may seem normal at first. You’ll start the service and CentOS will not complain. Then you run a ‘docker ps -a’ and see your containers are still there. That’s exciting. Then you start a container and thud…

[root~]# docker start jovial_wright
Error response from daemon: Unknown runtime specified docker-runc
Error: failed to start containers: jovial_wright

Go back and read the systemd file I posted a little closer. You’ll see definitions for runtimes that match your errors.

So let’s do an upgrade that will help with this. First and foremost, make backups. I do not take responsibility for any data loss.

  1. Stop docker. systemctl docker stop
  2. Copy your important files. In this case, /etc/docker/daemon.json and /usr/lib/systemd/system/docker.service
  3. Remove docker. In my case: yum remove docker docker-client docker-common
  4. yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
  5. yum install docker-ce
  6. Put your config file back into /etc/docker/daemon.json
  7. Adjust your docker systemd file to define the new locations of the docker runtime and docker proxy. Mine eneded up looking like this:

    ExecStart=/usr/bin/dockerd –tlsverify –tlscacert=/docker/SSL/ca.pem –tlscert=/docker/SSL/server-cert.pem –tlskey=/docker/SSL/server-key.pem \
    -H=0.0.0.0:2376 -H unix:///var/run/docker.sock \
    –add-runtime docker-runc=/usr/bin/docker-runc \
    –default-runtime=docker-runc \
    –exec-opt native.cgroupdriver=systemd \
    –userland-proxy-path=/usr/bin/docker-proxy

    Not that the the path to docker-runc and docker-proxy changed as well so it’s not just a copy-pasta affair.

Hope this helps.

Next Post

Leave a Reply

© 2018 fixyourserver.com

Theme by Anders Norén