Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# update apt-get
export DEBIAN_FRONTEND="noninteractive"
sudo apt-get update
# remove previously installed Docker
sudo apt-get purge lxc-docker*
sudo apt-get purge docker.io*
# add Docker repo
sudo apt-get install -y apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
cat > /etc/apt/sources.list.d/docker.list <<'EOF'
deb https://apt.dockerproject.org/repo debian-stretch main
EOF
sudo apt-get update
# install Docker
sudo apt-get install -y docker-engine
sudo service docker start
sudo docker run hello-world
# configure Docker user group permissions
sudo groupadd docker
sudo gpasswd -a ${USER} docker
sudo service docker restart
# set Docker to auto-launch on startup
sudo systemctl enable docker
@gmolveau

This comment has been minimized.

Copy link

@gmolveau gmolveau commented Feb 1, 2017

I had some troubles with the "deb https://apt.dockerproject.org/repo debian-stretch main" on a fresh kali installation. I had to change the "https" to "http" to make it work.

@jesmith0

This comment has been minimized.

Copy link

@jesmith0 jesmith0 commented Feb 5, 2017

works great. thanks!

@laumair

This comment has been minimized.

Copy link

@laumair laumair commented Mar 17, 2017

Works perfectly.

@emoa

This comment has been minimized.

Copy link

@emoa emoa commented Mar 26, 2017

works to kali 2016.2? i dont break my kali 🇼🇸

@ManuelSimon

This comment has been minimized.

Copy link

@ManuelSimon ManuelSimon commented Apr 5, 2017

Perfect!

@sagartambe2015

This comment has been minimized.

Copy link

@sagartambe2015 sagartambe2015 commented Apr 8, 2017

Yep It's work. Thanks

@f3rn4s

This comment has been minimized.

Copy link

@f3rn4s f3rn4s commented May 6, 2017

Add tons of problems,some help plz

Get:2 http://apt.dockerproject.org/repo debian-stretch InRelease [48.7 kB]
Hit:1 http://archive-4.kali.org/kali kali-rolling InRelease
Ign:2 http://apt.dockerproject.org/repo debian-stretch InRelease
Fetched 48.7 kB in 1s (37.4 kB/s)
Reading package lists... Done
W: GPG error: http://apt.dockerproject.org/repo debian-stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F76221572C52609D
W: The repository 'http://apt.dockerproject.org/repo debian-stretch InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'lxc-docker-virtual-package' for glob 'lxc-docker*'
Note, selecting 'lxc-docker' for glob 'lxc-docker*'
Package 'lxc-docker' is not installed, so not removed
Package 'lxc-docker-virtual-package' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'docker.io' for glob 'docker.io*'
Package 'docker.io' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version (1.4.1).
ca-certificates is already the newest version (20161130).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Executing: /tmp/apt-key-gpghome.FQk4Ul60gk/gpg.1.sh --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.FQk4Ul60gk/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr
Get:1 http://apt.dockerproject.org/repo debian-stretch InRelease [48.7 kB]
Ign:1 http://apt.dockerproject.org/repo debian-stretch InRelease
Hit:2 http://archive-4.kali.org/kali kali-rolling InRelease
Fetched 48.7 kB in 0s (60.9 kB/s)
Reading package lists... Done
W: GPG error: http://apt.dockerproject.org/repo debian-stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F76221572C52609D
W: The repository 'http://apt.dockerproject.org/repo debian-stretch InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
aufs-dkms aufs-tools cgroupfs-mount dkms linux-compiler-gcc-6-x86
linux-headers-4.9.0-kali4-amd64 linux-headers-4.9.0-kali4-common
linux-headers-amd64 linux-kbuild-4.9
Suggested packages:
aufs-dev python3-apport
The following NEW packages will be installed:
aufs-dkms aufs-tools cgroupfs-mount dkms docker-engine
linux-compiler-gcc-6-x86 linux-headers-4.9.0-kali4-amd64
linux-headers-4.9.0-kali4-common linux-headers-amd64 linux-kbuild-4.9
0 upgraded, 10 newly installed, 0 to remove and 3 not upgraded.
Need to get 31.1 MB of archives.
After this operation, 163 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
docker-engine
E: There were unauthenticated packages and -y was used without --allow-unauthenticated
Failed to start docker.service: Unit docker.service not found.
sudo: docker: command not found
groupadd: group 'docker' already exists
Adding user root to group docker
Failed to restart docker.service: Unit docker.service not found.
Failed to enable unit: File docker.service: No such file or directory

@galsenpro

This comment has been minimized.

Copy link

@galsenpro galsenpro commented May 12, 2017

@f3rn4s,
We have the same problem. If you will have the solution

@WeedBilbao

This comment has been minimized.

Copy link

@WeedBilbao WeedBilbao commented May 22, 2017

Nice work man!

@jeffersonbenson

This comment has been minimized.

Copy link

@jeffersonbenson jeffersonbenson commented May 26, 2017

Seems to work for me after adding --allow-unauthenticated to line 21

@nikallass

This comment has been minimized.

Copy link

@nikallass nikallass commented May 31, 2017

Thanks! I make this for kali 2017.1 x64 for new Docker-ce https://gist.github.com/nikallass/e5124756d0e2bdcf8981827f3ed40bcc

@brunocascio

This comment has been minimized.

Copy link

@brunocascio brunocascio commented Jun 20, 2017

Thanks! Works good

@vanmart

This comment has been minimized.

Copy link

@vanmart vanmart commented Jul 31, 2017

GREATE!!! THANKS A LOT!

i was having problems adding the repo "permissions denied" so i tried this:
sudo nano /etc/apt/sources.list.d/docker.list
this will create a docker.list file. inside you must paste the line of code of your repo
deb https://apt.dockerproject.org/repo debian-stretch main
Save.
sudo apt-get update.

Done. docker will exist. then continue the script steps.

@x73

This comment has been minimized.

Copy link

@x73 x73 commented Aug 2, 2017

Thanks for your script, unfortunately I have an issue during installing 'docker-engine' package: "E: Package 'docker-engine' has no installation candidate". I installed 'docker' package, but when trying to start a service getting following: "Failed to start docker.service: Unit docker.service not found."

Meanwhile 'apt-cache policy docker' returns me:

docker:
Installed: 1.5-1+b1
Candidate: 1.5-1+b1
Version table:
*** 1.5-1+b1 500
500 http://http.kali.org/kali kali-rolling/main i386 Packages
100 /var/lib/dpkg/status

Here is details of my kali: Linux kali 4.9.0-kali3-686-pae #1 SMP Debian 4.9.18-1kali1 (2017-04-04) i686 GNU/Linux

Seems that tried a lot of different manipulations but no success..

Thanks

@SrEnrique

This comment has been minimized.

Copy link

@SrEnrique SrEnrique commented Aug 15, 2017

This works for me after install software-properties-common and dirmngr, between lines 17 and 18
apt install software-properties-common dirmngr

@mzmn-se

This comment has been minimized.

Copy link

@mzmn-se mzmn-se commented Jan 25, 2018

wow great docs, thanks

@akshaybrij

This comment has been minimized.

Copy link

@akshaybrij akshaybrij commented Feb 4, 2018

Thanks Man Really Helped me !!!

@SHUBHAM-DHANUKA

This comment has been minimized.

Copy link

@SHUBHAM-DHANUKA SHUBHAM-DHANUKA commented Feb 7, 2018

Thanks man, it works perfectly.

@lsarkisov

This comment has been minimized.

Copy link

@lsarkisov lsarkisov commented Apr 22, 2019

Thank you! Just one important remark: you need to log out/log in after sudo gpasswd -a ${USER} docker

@SameerTi

This comment has been minimized.

Copy link

@SameerTi SameerTi commented Nov 5, 2019

cat /etc/issue
Kali GNU/Linux Rolling \n \l

This script kind of broken "sudo apt install...." completely

Prior running this script, i was able to install "Docker" by "sudo apt install docker"

However my docker service was not running, so i installed this script, it changed "/etc/apt/sources.list" in such a way that... now it's not able to connect to "https://http.kali.org" or anything else

when i ping "www.google.com" i get msgs back... so i don't think so it's proxy or network issue

`
root@kali:/opt# ./docker.sh
Err:1 https://download.docker.com/linux/debian stretch InRelease
Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:1000:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:fc00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:ac00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:e00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:b200:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:b000:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:d800:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:400:3:db06:4200:93a1). - connect (101: Network is unreachable) Could not connect to download.docker.com:443 (54.230.71.69), connection timed out Could not connect to download.docker.com:443 (54.230.71.11), connection timed out Could not connect to download.docker.com:443 (54.230.71.18), connection timed out Could not connect to download.docker.com:443 (54.230.71.125), connection timed out
Reading package lists... Done
W: Failed to fetch https://download.docker.com/linux/debian/dists/stretch/InRelease Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:1000:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:fc00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:ac00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:e00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:b200:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:b000:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:d800:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:215c:400:3:db06:4200:93a1). - connect (101: Network is unreachable) Could not connect to download.docker.com:443 (54.230.71.69), connection timed out Could not connect to download.docker.com:443 (54.230.71.11), connection timed out Could not connect to download.docker.com:443 (54.230.71.18), connection timed out Could not connect to download.docker.com:443 (54.230.71.125), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package lxc-docker*
E: Couldn't find any package by glob 'lxc-docker*'
E: Couldn't find any package by regex 'lxc-docker*'
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package docker.io*
E: Couldn't find any package by glob 'docker.io*'
E: Couldn't find any package by regex 'docker.io*'
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'apt' instead of 'apt-transport-https'
apt is already the newest version (1.8.3).
ca-certificates is already the newest version (20190110).
The following package was automatically installed and is no longer required:
wmdocker
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Executing: /tmp/apt-key-gpghome.CdXrE49r4O/gpg.1.sh --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
gpg: keyserver receive failed: Connection timed out
Err:1 https://apt.dockerproject.org/repo debian-stretch InRelease
Could not connect to apt.dockerproject.org:443 (13.249.218.107), connection timed out
Err:2 https://download.docker.com/linux/debian stretch InRelease
Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:1800:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:fc00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:ec00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:9c00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:d000:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:a00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:ee00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:7600:3:db06:4200:93a1). - connect (101: Network is unreachable) Could not connect to download.docker.com:443 (99.86.19.90), connection timed out Could not connect to download.docker.com:443 (99.86.19.87), connection timed out Could not connect to download.docker.com:443 (99.86.19.45), connection timed out Could not connect to download.docker.com:443 (99.86.19.76), connection timed out
Reading package lists... Done
W: Failed to fetch https://download.docker.com/linux/debian/dists/stretch/InRelease Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:1800:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:fc00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:ec00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:9c00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:d000:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:a00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:ee00:3:db06:4200:93a1). - connect (101: Network is unreachable) Cannot initiate the connection to download.docker.com:443 (2600:9000:2014:7600:3:db06:4200:93a1). - connect (101: Network is unreachable) Could not connect to download.docker.com:443 (99.86.19.90), connection timed out Could not connect to download.docker.com:443 (99.86.19.87), connection timed out Could not connect to download.docker.com:443 (99.86.19.45), connection timed out Could not connect to download.docker.com:443 (99.86.19.76), connection timed out
W: Failed to fetch https://apt.dockerproject.org/repo/dists/debian-stretch/InRelease Could not connect to apt.dockerproject.org:443 (13.249.218.107), connection timed out
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package docker-engine
Failed to start docker.service: Unit docker.service not found.
sudo: docker: command not found
groupadd: group 'docker' already exists
Adding user root to group docker
Failed to restart docker.service: Unit docker.service not found.
Failed to enable unit: Unit file docker.service does not exist.

===========

root@kali:/opt# ping www.google.com
PING www.google.com (172.217.166.100) 56(84) bytes of data.
64 bytes from maa05s09-in-f4.1e100.net (172.217.166.100): icmp_seq=1 ttl=53 time=28.0 ms
64 bytes from maa05s09-in-f4.1e100.net (172.217.166.100): icmp_seq=2 ttl=53 time=39.3 ms
64 bytes from maa05s09-in-f4.1e100.net (172.217.166.100): icmp_seq=3 ttl=53 time=34.2 ms
`

@0dayCTF

This comment has been minimized.

Copy link

@0dayCTF 0dayCTF commented Dec 11, 2019

Lifesaver! Thank you

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