Last active
July 9, 2017 19:21
-
-
Save dayglojesus/8a76f6a9d141a00188facc1d468c8802 to your computer and use it in GitHub Desktop.
preflight script for docker upgrade from 17.03.0-ce to 17.06.0-ce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# pre-flight script for docker upgrade from 17.03.0-ce to 17.06.0-ce | |
# Issue: https://github.com/docker/for-linux/issues/49 | |
require 'json' | |
module JSON | |
def self.load_file(path) | |
parse File.read(path) | |
end | |
end | |
Dir.glob('/run/runc/*/state.json') do |file| | |
data = JSON.load_file(file) | |
if data['config']['cgroups']['memory_swappiness'] == -1 | |
data['config']['cgroups']['memory_swappiness'] = nil | |
File.write file, data.to_json | |
end | |
end | |
Dir.glob('/run/docker/libcontainerd/*/config.json') do |file| | |
data = JSON.load_file(file) | |
data['process']['capabilities'] = if data['process']['capabilities'].respond_to?(:flatten) | |
%w{bounding effective inheritable permitted}.inject({}) do |memo, key| | |
memo.merge!({ key => data['process']['capabilities'] }) | |
end | |
File.write file, data.to_json | |
end | |
end | |
Dir.glob('/run/docker/libcontainerd/containerd/*/init/process.json') do |file| | |
data = JSON.load_file(file) | |
data['capabilities'] = if data['capabilities'].respond_to?(:flatten) | |
%w{bounding effective inheritable permitted}.inject({}) do |memo, key| | |
memo.merge!({ key => data['capabilities'] }) | |
end | |
File.write file, data.to_json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment