Skip to content

Instantly share code, notes, and snippets.

@frgomes
Last active June 6, 2021 18:52
Show Gist options
  • Save frgomes/a6f889583860f5b330c06c8b46fa0f42 to your computer and use it in GitHub Desktop.
Save frgomes/a6f889583860f5b330c06c8b46fa0f42 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

heyost 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
Copy link

koffi 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
Copy link

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
Copy link

rkevinburton 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
Copy link

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
Copy link

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
Copy link

hpanago commented Jan 7, 2018

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

@lagaree
Copy link

lagaree 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
Copy link

Thanks!

@cetver
Copy link

cetver commented Mar 31, 2020

FROM ***CHANGE-ME***

USER root

RUN rm /etc/apt/sources.list.d/jessie-backports.list

RUN apt-get update

RUN apt-get install -y sudo curl

RUN curl -fsSL https://get.docker.com -o get-docker.sh

RUN sh get-docker.sh

RUN apt-get clean

RUN rm -rf /var/lib/apt/lists/* 

RUN rm -rf /tmp/* 

RUN rm -rf /var/tmp/* 

RUN rm -rf /usr/share/doc/*

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