Skip to content

Instantly share code, notes, and snippets.

@apolloclark
Last active February 23, 2022 15:10
Show Gist options
  • Save apolloclark/f0e3974601346883c731 to your computer and use it in GitHub Desktop.
Save apolloclark/f0e3974601346883c731 to your computer and use it in GitHub Desktop.
#!/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
@brunocascio
Copy link

Thanks! Works good

@vanmart
Copy link

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

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

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

@monir-zaman
Copy link

wow great docs, thanks

@akshaybrij
Copy link

Thanks Man Really Helped me !!!

@SHUBHAM-DHANUKA
Copy link

Thanks man, it works perfectly.

@lsarkisov
Copy link

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

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

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