4
url='https://get.docker.com/'
7
command -v "$@" > /dev/null 2>&1
10
echo_docker_as_nonroot() {
11
if command_exists docker && [ -e /var/run/docker.sock ]; then
14
$sh_c 'docker version'
17
status-set active "Docker installed and ready"
19
[ "$user" != 'root' ] && your_user="$user"
20
# intentionally mixed spaces and tabs here -- tabs are stripped by "<<-EOF", spaces are kept in the output
23
If you would like to use Docker as a non-root user, you should now consider
24
adding your user to the "docker" group with something like:
26
sudo usermod -aG docker $your_user
28
Remember that you will have to log out and back in for this to take effect!
33
get_debian_dist_version() {
52
Error: you are not using a 64bit platform.
53
Docker currently only supports 64bit platforms.
59
user="$(id -un 2>/dev/null || true)"
62
if [ "$user" != 'root' ]; then
63
if command_exists sudo; then
65
elif command_exists su; then
69
Error: this installer needs the ability to run commands as root.
70
We are unable to find either "sudo" or "su" available to make this happen.
77
if command_exists curl; then
79
elif command_exists wget; then
81
elif command_exists busybox && busybox --list-modules | grep -q wget; then
82
curl='busybox wget -qO-'
85
# check to see which repo they are trying to install from
87
if [ "https://test.docker.com/" = "$url" ]; then
89
elif [ "https://experimental.docker.com/" = "$url" ]; then
93
# perform some very rudimentary platform detection
96
if command_exists lsb_release; then
97
lsb_dist="$(lsb_release -si)"
99
if [ -z "$lsb_dist" ] && [ -r /etc/lsb-release ]; then
100
lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
102
if [ -z "$lsb_dist" ] && [ -r /etc/debian_version ]; then
105
if [ -z "$lsb_dist" ]; then
106
if [ -r /etc/centos-release ] || [ -r /etc/redhat-release ]; then
110
if [ -z "$lsb_dist" ] && [ -r /etc/os-release ]; then
111
lsb_dist="$(. /etc/os-release && echo "$ID")"
114
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
119
if command_exists lsb_release; then
120
dist_version="$(lsb_release --codename | cut -f2)"
122
if [ -z "$dist_version" ] && [ -r /etc/lsb-release ]; then
123
dist_version="$(. /etc/lsb-release && echo "$DISTRIB_CODENAME")"
128
dist_version="$(cat /etc/debian_version | sed 's/\/.*//' | sed 's/\..*//')"
129
case "$dist_version" in
131
dist_version="jessie"
134
dist_version="wheezy"
140
dist_version="$(rpm -q --whatprovides redhat-release --queryformat "%{VERSION}\n" | sed 's/\/.*//' | sed 's/\..*//')"
144
if command_exists lsb_release; then
145
dist_version="$(lsb_release --codename | cut -f2)"
147
if [ -z "$dist_version" ] && [ -r /etc/os-release ]; then
148
dist_version="$(. /etc/os-release && echo "$VERSION_ID")"
159
$sh_c 'sleep 3; yum -y -q install docker'
161
echo_docker_as_nonroot
166
export DEBIAN_FRONTEND=noninteractive
167
status-set maintenance "Updating package list"
170
if [ -z "$did_apt_get_update" ]; then
171
( set -x; $sh_c 'sleep 3; apt-get update' )
176
# aufs is preferred over devicemapper; try to ensure the driver is available.
177
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
178
status-set maintenance "Installing kernel modules to support union filesystem"
179
if uname -r | grep -q -- '-generic' && dpkg -l 'linux-image-*-generic' | grep -q '^ii' 2>/dev/null; then
180
kern_extras="linux-image-extra-$(uname -r) linux-image-extra-virtual"
183
( set -x; $sh_c 'sleep 3; apt-get install -y -q '"$kern_extras" ) || true
185
if ! grep -q aufs /proc/filesystems && ! $sh_c 'modprobe aufs'; then
186
echo >&2 'Warning: tried to install '"$kern_extras"' (for AUFS)'
187
echo >&2 ' but we still have no AUFS. Docker may not work. Proceeding anyways!'
191
echo >&2 'Warning: current kernel is not supported by the linux-image-extra-virtual'
192
echo >&2 ' package. We have no AUFS support. Consider installing the packages'
193
echo >&2 ' linux-image-virtual kernel and linux-image-extra-virtual for AUFS support.'
198
# install apparmor utils if they're missing and apparmor is enabled in the kernel
199
# otherwise Docker will fail to start
200
if [ "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" = 'Y' ]; then
201
status-set maintenance "Installing apparmor security policies"
202
if command -v apparmor_parser >/dev/null 2>&1; then
203
echo 'apparmor is enabled in the kernel and apparmor utils were already installed'
205
echo 'apparmor is enabled in the kernel, but apparmor_parser missing'
207
( set -x; $sh_c 'sleep 3; apt-get install -y -q apparmor' )
211
if [ ! -e /usr/lib/apt/methods/https ]; then
212
status-set maintenance "Installing HTTPS support"
214
( set -x; $sh_c 'sleep 3; apt-get install -y -q apt-transport-https ca-certificates' )
216
if [ -z "$curl" ]; then
218
( set -x; $sh_c 'sleep 3; apt-get install -y -q curl ca-certificates' )
222
status-set maintenance "Adding PPA and installing docker"
224
$sh_c "apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D"
225
$sh_c "mkdir -p /etc/apt/sources.list.d"
226
$sh_c "echo deb https://apt.dockerproject.org/repo ${lsb_dist}-${dist_version} ${repo} > /etc/apt/sources.list.d/docker.list"
227
$sh_c 'sleep 3; apt-get update; apt-get install -y -q docker-engine'
230
echo_docker_as_nonroot
235
status-set maintenance "Installing docker"
236
$sh_c "cat >/etc/yum.repos.d/docker-${repo}.repo" <<-EOF
237
[docker-${repo}-repo]
238
name=Docker ${repo} Repository
239
baseurl=https://yum.dockerproject.org/repo/${repo}/${lsb_dist}/${dist_version}
242
gpgkey=https://yum.dockerproject.org/gpg
244
if [ "$lsb_dist" = "fedora" ] && [ "$dist_version" -ge "22" ]; then
247
$sh_c 'sleep 3; dnf -y -q install docker-engine'
252
$sh_c 'sleep 3; yum -y -q install docker-engine'
255
echo_docker_as_nonroot
260
# intentionally mixed spaces and tabs here -- tabs are stripped by "<<-'EOF'", spaces are kept in the output
263
Either your platform is not easily detectable, is not supported by this
264
installer script (yet - PRs welcome! [hack/install.sh]), or does not yet have
265
a package for Docker. Please visit the following URL for more detailed
266
installation instructions:
268
https://docs.docker.com/en/latest/installation/