# Docker basics and Images

### 1. Docker Images

Check out: <https://hub.docker.com/>

### 2. Useful Docker commands

#### Docker Repository file:

> cat /etc/apt/sources.list.d/docker.list

![Docker Repository file](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhDZtzDdr57jz3VN9Ij%2F-MhO6PtV8H0cgCYCXaEj%2Fdocker01.png?alt=media\&token=cbd10c50-c092-42ae-8618-9eeedc530a27)

#### Check docker service:

> sudo service docker status

![Docker service status](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhDZtzDdr57jz3VN9Ij%2F-MhOAuBYdvRwJMX2r4Sd%2Fdocker02.png?alt=media\&token=22ebb846-10f4-470b-b6cf-0d99757a35db)

#### Download and run Docker Image

> sudo docker pull hello-world
>
> sudo docker run hello-world

![Docker Installation is working :)](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhDZtzDdr57jz3VN9Ij%2F-MhOC6id5Q-jeU62NIeH%2Fdocker03.png?alt=media\&token=3d6b0859-7a5c-4fec-917a-9dd8ce8b4f54)

#### List and remove Docker Images

> sudo docker images
>
> sudo docker ps -a

![List docker images](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhDZtzDdr57jz3VN9Ij%2F-MhODZm5FXjbWIwTT1aH%2Fdocker04.png?alt=media\&token=82058e98-0e9d-4d08-b013-cd3b9569f194)

> sudo docker rmi -f opensecurity/mobile-security-framework-mobsf

![Remove specific docker image](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhDZtzDdr57jz3VN9Ij%2F-MhOF2RK65HInmPtVuZu%2Fdocker05.png?alt=media\&token=845f2189-64d5-43c9-b5f0-b45547a4bac0)

#### Interact with docker image

> sudo docker pull ubuntu
>
> sudo docker run --name customUbuntu -itd ubuntu /bin/bash
>
> sudo docker exec -it custumUbuntu /bin/bash

![bash inside docker container](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhOFXdrpanwVN6qO0iD%2F-MhOJ-IUzoW0bkc2wRGa%2Fdocker06.png?alt=media\&token=4bcae3e6-ee53-4903-8923-4093cafa3e21)

Docker service manage  ip adresses:

First container get's the ip address 172.17.0.2

#### Portforwarding to docker container

> sudo docker create --name customUbuntu2 -p 8090:80 -p 88:443 -it ubuntu /bin/bash
>
> docker start customUbuntu2
>
> docker ps

![](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhOFXdrpanwVN6qO0iD%2F-MhOL9wSKyfU7KSbPsog%2Fdocker07.png?alt=media\&token=5f72a872-bad2-43fc-a589-b25f58f8970b)

If you have want to pull multiple docker images, it's usefull to register a free account on [https://hub.docker.com ](https://hub.docker.com)

> docker login

![docker login from zsh](https://3977837039-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfT0VPyK6X13Egd9pzy%2F-MhOFXdrpanwVN6qO0iD%2F-MhOQQeo3lPBHzttgN9v%2Fdocker08.png?alt=media\&token=4e89af72-476b-4007-9485-1cf5accbffd7)

### 3. Docker Images for Security training

* [Dawn Vulnerable Webapp](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/damn-vulnerable-webapp)
* [bWAPP](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/bwapp)
* [Juice Webshop](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/juice-webshop)
* [Webgoat](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/webgoat)
* [Metasploitable 2](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/metasploitable-2)
* [Metasploitable 3](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/metasploitable-3)
* [MISP Docker (old)](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/misp-docker-old)
* [MISP Docker (new)](https://cas-cyber.gitbook.io/cas-cybersecurity/docker-basics/misp-docker-new)
