Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installs Docker on Elementary OS 0.4 (Loki)
#!/bin/bash
sudo apt-get install apt-transport-https ca-certificates -y
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo rm -f /etc/apt/sources.list.d/docker.list
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -u -cs) \
stable"
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
sudo apt-get install docker-engine
sudo service docker start
sudo groupadd docker
sudo usermod -aG docker $USER
# NOTE: you'll need to exit and reenter the shell before your user is actually recognised as part of the 'docker' group.
@ryuheechul

This comment has been minimized.

Copy link

commented Mar 10, 2017

Thanks for sharing!

You can also install docker-ce with this snippet but need to change according to this, https://store.docker.com/editions/community/docker-ce-server-ubuntu

@p202pbrianmackey

This comment has been minimized.

Copy link

commented May 23, 2017

Are you supposed to install docker with sudo? When I run docker ps I get permission denied.

@gkawamoto

This comment has been minimized.

Copy link

commented May 26, 2017

@JamesDaniel

This comment has been minimized.

Copy link

commented May 30, 2017

I encountered one problem. Line 4 wouldn't execute properly. I needed to execute this script in a root terminal. Even prepending sudo to that line didn't work in a non root terminal.

After adding your user to the docker group you also need to log out and back in. Correct me if I'm wrong but this is the case with ubuntu16 server.

BTW thanks for this gist. It really saved me time.

-----------------UPDATE-----------------

I noticed I couldn't use docker without sudo. I changed the last line to this:
echo 'Enter user who will use docker without sudo:'
read USER
sudo usermod -aG docker $USER

I'm using scripts to automate certain things on my laptop and server so I copied this script with slight changes. So far I am not having any issues with my version. Credit goes to @ChrisTimperley of course.
https://github.com/JamesDaniel/laptop-scripts/blob/master/docker_install.sh

@NathanTheGr8

This comment has been minimized.

Copy link

commented Jun 1, 2017

I would just change line 5 to

sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       xenial \
       stable"

for eOS loki. The one from the Docker dev site wants to put loki install of xenial. I am not sure of a way to eOS's ubuntu codename base

@sebolio

This comment has been minimized.

Copy link

commented Jul 5, 2017

Line 5 needs sudo on tee

echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
@fizxmike

This comment has been minimized.

Copy link

commented Jul 23, 2017

I'd add the following 2 lines

sudo service docker start

echo "please log out then log back in since you have just been added to the docker system user group which is needed to run docker without sudo..."
@artnicbr

This comment has been minimized.

Copy link

commented Jul 28, 2017

After following the instructions I get this error after trying to install
$ sudo apt-get install docker-engine
"E: Package 'docker-engine' has no installation candidate"

Am I missing something?

@tsiory

This comment has been minimized.

Copy link

commented Sep 23, 2017

add sudo for tee then it works fine for me :)

@tomsiwik

This comment has been minimized.

Copy link

commented Nov 21, 2017

You can stick to the docker tutorial completely. https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#set-up-the-repository
The only change you need to do is a the -u flag in the lsb_release subshell command. This gives you the codename of the underlying system. You can do this pretty much with every installation that fails if the apt repository 404's.

It's very similar to @NathanTheGr8 answer, though. It's just future proof for all elementary versions.

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -u -cs) \
   stable"
@ChrisTimperley

This comment has been minimized.

Copy link
Owner Author

commented Dec 9, 2017

Thanks for all of the suggestions! :-) I've incorporated most of them. I had absolutely no idea that anyone had noticed this script; I'm glad that it's been at least a little helpful to you.

Is it possible to get notifications for gists?

@MAJA-Lin

This comment has been minimized.

Copy link

commented Dec 27, 2017

I think docker-engine has been removed?

sudo apt-get install docker-engine
is not working now.

I changed to docker-ce and it worked perfectly.

@Philippe-Collignon

This comment has been minimized.

Copy link

commented Mar 19, 2018

The script failed on my system ... Loki Linux 4.13.0-32-generic

I followed the installation guide on Docker and replace the "loki" lsb_release by "xenial" and everything works :

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable"
sudo apt-get update
sudo apt-get install docker-ce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.