Docker installation and basic use in Pentesting

Introduction

In this module we are going to learn docker, nowadays its become more useful for everyone. You can build and deploy services in it in the form of container. It allows you to customize, clone your container, and also you can push/upload a customized image by the docker hub. We can build our penetration testing image easily and use it smoothly in docker. If you want to build a penetration testing lab, its very easy to set up a lab in docker then your host system. So let’s start…

What is Docker?

Docker is a container technology that provides a platform as a service that uses OS-level virtualization to deliver software in packages known as containers.

You can create one or more containers from one os image and customize them as per your need, containers are isolated from one another and bundle their software, libraries, and configuration files; they can communicate with each other through well-defined channels.

Step by Step installation

# apt install docker.io docker docker-engine

After the successful installation of docker enable it.

# service docker enable

And start docker

# service docker start

You can also disable it

# service docker disable

you can also stop docker temporarily

# service docker stop

Docker images

Images in docker are packaged services or environments, like iso images to boot the system. Images are created with the build command, and they’ll produce a container when it started with a run. Images are stored in a Docker registry such as registry.hub.docker.com

To list docker images simply run command

# docker images -a

Docker container

Docker is an instance of an image, the container is an instance of a class—a runtime object.

**To list all containers **

# docker ps -a

Building Linux containers to use in docker

All you have to execute a simple command based on your need or can search containers on hub.docker.com.

Example if you want to install ubuntu 32-bit container then pull 32-bit ubuntu image

# docker -h

# docker pull m0elnx/ubuntu-32bit

This will pull the image in your system and now you can launch your instance from it

it - interactive terminal

name - to put the name of your instance

# docker images -a

# docker run -it --name hacker m0elnx/ubuntu-32bit

you can stop it using

# exit

if you want to start it again

# docker start hacker

# docker attach hacker

And now you can launch your new OS in 2 seconds

What about use kali instance in docker

simply install as above

# docker pull kalilinux/kali-linux-docker
# docker run -it --name elitehacker kalilinux/kali-linux-docker

you can install parrot sec also

# docker pull parrotsec/security
# docker run -it --name hactivist parrotsec/security

Download docker cheatsheet learn more about docker click here

Conclusion

Install docker, follow steps, I will also explain how to set up the lab in docker, or you can try it yourself, it’s easy.