Kali Linux Intrusion and Exploitation Cookbook
上QQ阅读APP看书,第一时间看更新

Installing Docker on Kali Linux

In this recipe, we will be to installing and setting-up Docker on Kali Linux.

Getting ready

To step through this recipe, you will need a running Kali Linux in Oracle Virtualbox or VMware, and an Internet connection. No other prerequisites are required.

How to do it...

For this recipe, you need to perform the following steps:

  1. At the time of writing this book, Kali Linux 2.0 Rolling is based on Debian Wheezy and therefore these steps will only work for Debian Wheezy based Kali Linux. In future, if Kali is updated, then kindly check the latest steps to install Docker from the Docker documentation.
  2. In your terminal window open /etc/apt/sources.list.d/backports.list in your favorite editor. If the file doesn't exist, create it.
  3. Remove any existing entries and add an entry for backports on Debian wheezy:
     deb http://http.debian.net/debian wheezy-backports main
    
  4. Update the package information and ensure that APT works with the HTTPS method, and that CA certificates are installed:
     $ apt-get update
     $ apt-get install apt-transport-https ca-certificates
    
  5. Add the GPG key:
     $ apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
    
  6. Open /etc/apt/sources.list.d/docker.list in your favorite editor. If the file doesn't exist, create it.
  7. Remove any existing entries and add an entry for backports on Debian wheezy:
     $ deb https://apt.dockerproject.org/repo debian-wheezy main
    
  8. Update the package information and verify that APT is pulling from the right repository:
     $ apt-get update && apt-cache policy docker-engine
    
  9. Install Docker:
     $ apt-get install docker-engine
    
  10. Start the Docker daemon:
     $ service docker start
    
  11. Verify that Docker is installed properly:
     $ docker run hello-world
    

Since, you're already logged in as root in your Kali Linux installation, you don't need to use sudo. But it is important to note that the docker daemon always runs as the root user and the docker daemon binds to a Unix socket instead of a TCP port. By default, that Unix socket is owned by the user root, and so, you will need to use the preceding commands with sudo, if you are not logged in as root.

How it works...

In this recipe, we have added the docker source list so that we can fetch the Docker updates every time we use the apt-get update command on our system. Then, update the apt-get sources and install the prerequisites required for installing Docker. We added the GPG key to ensure that whatever updates we are installing are valid official unchanged packages. After all this basic configuration, we ran a basic apt-cache to ensure APT is fetching the docker-engine from the right repository. Finally, we installed docker-engine using apt-get.