Skip to content

Instantly share code, notes, and snippets.

@tsabat
Forked from BretFisher/docker-xenial-copy-paste.sh
Last active September 12, 2017 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsabat/1dcbfe65fbdd5be587dbe938505d2d21 to your computer and use it in GitHub Desktop.
Save tsabat/1dcbfe65fbdd5be587dbe938505d2d21 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 full shell script docker-xenial.sh
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
mkdir -p /etc/apt/sources.list.d && \
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list && \
service lxcfs stop && apt-get remove -y -q lxc-common lxcfs lxd lxd-client && \
apt-get update -q && apt-get upgrade -y -q && \
apt-get install -y -q linux-image-extra-$(uname -r) linux-image-extra-virtual && \
apt-get install -y -q docker-engine && \
mkdir -p /etc/systemd/system/docker.service.d && \
echo $'[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --userns-remap=default --storage-driver aufs' > /etc/systemd/system/docker.service.d/namespaces.conf && \
systemctl daemon-reload && \
systemctl restart docker.service
#!/bin/sh
# add's docker official ppa package source for Docker engine
# does not include docker-compose or docker-machine
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
mkdir -p /etc/apt/sources.list.d
echo deb https://apt.dockerproject.org/repo ubuntu-xenial main > /etc/apt/sources.list.d/docker.list
# Other Package Branches, experimental gives you extra features that may change in future
#echo deb https://apt.dockerproject.org/repo ubuntu-xenial testing > /etc/apt/sources.list.d/docker.list
#echo deb https://apt.dockerproject.org/repo ubuntu-xenial experimental > /etc/apt/sources.list.d/docker.list
# 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 aufs for docker storage driver
apt-get install -y -q linux-image-extra-$(uname -r) linux-image-extra-virtual
# install latest release (main branch) version of docker
apt-get install -y -q docker-engine
#
# 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-engine=1.12.1* --allow-change-held-packages
# hold to that version
#apt-mark hold docker-engine
# remove hold later for upgrade
# apt-mark unhold docker-engine
# see what upgrade options exist
# apt-cache policy docker-engine
# edit dockerd startup to enable namespaces and ensure aufs
# note namespace won't work in all scenerios, like --net=host,
# but its tighter security so it's recommended to try using first
mkdir -p /etc/systemd/system/docker.service.d
echo $'[Service]\nExecStart=\nExecStart=/usr/bin/dockerd -H fd:// --userns-remap=default --storage-driver aufs --label codepen.service="cpor"' > /etc/systemd/system/docker.service.d/namespaces.conf
systemctl daemon-reload
systemctl restart docker.service
@hegdedarsh
Copy link

HI , I used your docker-xenial.sh script and got the below error for installing Docker, can you please help me out.

hegdedarsh@hegdedarsh-Inspiron-N5010:~$ ./Docker_Installation.sh
Executing: /tmp/tmp.PaiTCBX5HZ/gpg.1.sh --keyserver
hkp://p80.pool.sks-keyservers.net:80
--recv-keys
58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server p80.pool.sks-keyservers.net
gpg: key 2C52609D: "Docker Release Tool (releasedocker) docker@docker.com" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
./Docker_Installation.sh: 8: ./Docker_Installation.sh: cannot create /etc/apt/sources.list.d/docker.list: Permission denied
Failed to stop lxcfs.service: Unit lxcfs.service not loaded.
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Reading package lists...
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
mkdir: cannot create directory ‘/etc/systemd/system/docker.service.d’: Permission denied
./Docker_Installation.sh: 44: ./Docker_Installation.sh: cannot create /etc/systemd/system/docker.service.d/namespaces.conf: Directory nonexistent
Failed to restart docker.service: Unit docker.service not found

@hegdedarsh
Copy link

And when I ran your copy-paste.sh script ,I got the below error.

root@hegdedarsh-Inspiron-N5010:~# ./Docker_Installtion.sh
Executing: /tmp/tmp.YwBGRBZN3n/gpg.1.sh --keyserver
hkp://p80.pool.sks-keyservers.net:80
--recv-keys
58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server p80.pool.sks-keyservers.net
gpg: key 2C52609D: "Docker Release Tool (releasedocker) docker@docker.com" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
Failed to stop lxcfs.service: Unit lxcfs.service not loaded.

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