Skip to content

Instantly share code, notes, and snippets.

@BretFisher
Last active December 1, 2023 01:39
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save BretFisher/deaa626107d4b976410946b243001bb4 to your computer and use it in GitHub Desktop.
Save BretFisher/deaa626107d4b976410946b243001bb4 to your computer and use it in GitHub Desktop.
Install Docker PPA on Ubuntu 16.04
# NOT FOR SHELL SCRIPT, but rather just for quick copy paste
# this is a copy-paste version with defaults of the full shell script docker-xenial.sh which is below this one in gist.
apt-get -y install apt-transport-https ca-certificates curl && \
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" && \
service lxcfs stop && apt-get remove -y -q lxc-common lxcfs lxd lxd-client && \
apt-get update -q && \
apt-get install -y -q docker-ce && \
printf '{ "userns-remap" : "default" , "storage-driver" : "overlay2" }' > /etc/docker/daemon.json && \
systemctl restart docker.service
#!/bin/sh
#
# add's docker official ppa package source for Docker engine and install it
# does not include docker-compose or docker-machine
# run as root
#
# ensure we have tools to install
apt-get -y install \
apt-transport-https \
ca-certificates \
curl
# add official package repo key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# add official package repo
# change stable on the last line to edge for beta-like monthly releases
# stable releases are quarterly
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# remove lxcfs, as we don't need it if we're doing docker
service lxcfs stop
apt-get remove -y -q lxc-common lxcfs lxd lxd-client
apt-get update -q
# install docker community (free) edition
apt-get -y install docker-ce
#
# FOR PRODUCTION, CONTROL VERSION MANUALLY
#
# install docker specific ver
# we allow held changes here in case we need to rerun, script will still work 2nd time
#apt-get install -y -q docker-ce=17.05.0* --allow-change-held-packages
# hold to that version
#apt-mark hold docker-ce
# remove hold later for upgrade
#apt-mark unhold docker-ce
# see what upgrade options exist
#apt-cache policy docker-ce
# edit dockerd startup to enable namespaces and ensure overlay2
# note namespace won't work in all scenerios, like --net=host,
# but its tighter security so it's recommended to try using first
# this now uses the daemon.json method rather that the old way of modifying systemd
printf '{ "userns-remap" : "default" , "storage-driver" : "overlay2" }' > /etc/docker/daemon.json
systemctl restart docker.service
@tsabat
Copy link

tsabat commented Oct 24, 2016

here's the output from /var/log/syslog

problem

Also, this results in a dollar-sign being added to the docker daemon args

oops

@BretFisher
Copy link
Author

Fixed the $ issue by replacing echo with printf. I can't replicate the "unauthenticated packages" error on 16.04 with AWS user-data @tsabat

@BretFisher
Copy link
Author

Stole this from Tim for ad-hoc daemon options.

if [[ -f extra_daemon_args.json ]]; then
  # back up the original
  mv /etc/docker/daemon.json /etc/docker/daemon.json.bak
  # take the original daemon file and combine it with the extra_daemon_args file
  # https://stackoverflow.com/questions/19529688/how-to-merge-2-json-file-using-jq
  jq -s '.[0] * .[1]' /etc/docker/daemon.json.bak extra_daemon_args.json > /etc/docker/daemon.json
fi

@hebronwatson
Copy link

hebronwatson commented Feb 7, 2018

Hey bud, thanks for this. you forgot to install software-properties-common and some may need python-software-properties as well
which results in a
add-apt-repository: command not found
error.

http://lifeonubuntu.com/ubuntu-missing-add-apt-repository-command/

thanks again! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment