Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Debian - install docker in Debian Jessie
#!/bin/bash
# compiled from https://docs.docker.com/engine/installation/linux/debian/#/debian-jessie-80-64-bit
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install apt-transport-https ca-certificates -y
sudo sh -c "echo deb https://apt.dockerproject.org/repo debian-jessie main > /etc/apt/sources.list.d/docker.list"
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-get update
sudo apt-cache policy docker-engine
sudo apt-get install docker-engine -y
sudo service docker start
sudo docker run hello-world
sudo group add docker
sudo groupadd docker
sudo gpasswd -a $USER docker
sudo service docker restart
@AnthonyMRodrigues

This comment has been minimized.

Copy link

commented Apr 26, 2017

great job.
I have a problem about "var/run/docker.sock: connect: permission denied".
And my resolution was "sudo usermod -a -G docker "
I hope that hepl someone

@heyost

This comment has been minimized.

Copy link

commented Jun 10, 2017

Thanks.
In case, have trouble when executing sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D trying using this method

gpg --keyserver pgpkeys.mit.edu --recv-key  F76221572C52609D      
gpg -a --export F76221572C52609D | sudo apt-key add -
@koffi

This comment has been minimized.

Copy link

commented Jun 28, 2017

Hi !
Please i'm looking for an ansible playbook to deploy docker swarm on 3 hosts : 2 for worker node et one for manager node

@vknyshuk

This comment has been minimized.

Copy link

commented Aug 14, 2017

Problem:

You are trying to run a docker container or do the docker tutorial, but you only get an error message like this:

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.26/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Solution:

Run this command in your favourite shell and then completely log out of your account and log back in (if in doubt, reboot!):
sudo usermod -a -G docker $USER
After doing that, you should be able to run the command without any issues. Run docker run hello-world as a normal user in order to check if it works. Reboot if the issue still persists.

Logging out and logging back in is required because the group change will not have an effect unless your session is closed.

@rkevinburton

This comment has been minimized.

Copy link

commented Aug 18, 2017

I get to here and the installation fails. The error messages are Greek to me. Any ideas?

sudo group add docker
sudo: group: command not found
@slgoldberg

This comment has been minimized.

Copy link

commented Sep 29, 2017

Thanks for making this, but unfortunately after I successfully add the source and key successfully, on the latest jessie version, no errors in your script at all -- until the one below, I wonder if something changed or if my environment is somehow not supported (see below).

The failure is that "apt-get install docker-engine" fails with:

E: Unable to locate package docker-engine

and then of course the rest of the script fails as a result as well.

I have tried three different ways to install Docker on my jessie machine (in fact, on three different machines, all set up slightly differently on different hardware/virtualization platforms, etc.) -- but something common for my installations is breaking this every time. (Whether I do it by hand, or use your script, I still get "not found" on docker-engine.

Is it possible it has something to do with apt getting in a weird state and I need to somehow clear it out? I haven't done anything weird, but since I added this repository using the sources.list.d/ method, using your script, and previously I added the lines directly to my main sources.list (but since commented them out!) .. it never once found "docker-engine", and so I can't imagine what it has cached that might be messing things up.

Anyway, the one question I am unsure of is about the architecture .. I'm running this script on a virtualized server that reports its architecture as "xenU.i386". Could that be the problem? I.e., will it only work on specific architectures? But that doesn't really make sense since it is not even finding the package... I am just unclear on how the third-party package libraries work exactly.

My sources.list is:

deb http://ftp.us.debian.org/debian jessie main contrib non-free
deb http://security.debian.org/ jessie/updates main contrib non-free
deb http://ftp.us.debian.org/debian jessie-backports main

My sources.list.d/docker.list is:

deb https://apt.dockerproject.org/repo debian-jessie main

The key installed fine, and the subsequent apt-get update worked fine and did load tons of stuff from the added apt.dockerproject.org source, e.g.:

Get:8 https://apt.dockerproject.org debian-jessie/main Translation-en_US [454 B]
Get:9 https://deb.nodesource.com jessie/main Translation-en [162 B]
Get:10 https://apt.dockerproject.org debian-jessie/main Translation-en [454 B]
Hit https://packages.gitlab.com jessie/main Sources           
Get:11 https://apt.dockerproject.org debian-jessie/main Translation-en_US [454 B]
... snip ...
Get:14 https://apt.dockerproject.org debian-jessie/main Translation-en [454 B]
... snip ...
Get:16 https://apt.dockerproject.org debian-jessie/main Translation-en_US [454 B]
... snip ...
Get:28 https://apt.dockerproject.org debian-jessie/main Translation-en_US [454 B]
Ign https://apt.dockerproject.org debian-jessie/main Translation-en_US
... more output here ...

Though I do wonder what that last line ("Ign ... ") means exactly... pretty telling, actually, isn't it? I just noticed it as I was pasting. It doesn't have any error thought accompanying it.. The reason for the skipped lines above is that many of them are other sources I have (such as nodeproject.org, etc.).

Any help would be greatly appreciated. I'm only asking it (and reporting it) here in case something changed in the package name and you need to update this (?). But I doubt it. It's worth a shot, anyway. So frustrated at this point trying to get it installed. :-(

Thanks again.

@ousamabenyounes

This comment has been minimized.

Copy link

commented Dec 19, 2017

Thank you...
Nice script worked for me.
I got some trouble installing docker on my old private server.
using this script everything was working :)

@hpanago

This comment has been minimized.

Copy link

commented Jan 7, 2018

Why dist-upgrade someone's system just to install docker?

@lagaree

This comment has been minimized.

Copy link

commented Mar 15, 2018

hi , my english is not very good . I try for code and i have this error ' no candidate for docker-engine'. i m using debian jessie. help me to fix it please

@Martlark

This comment has been minimized.

Copy link

commented Mar 21, 2018

Thanks!

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.