Contains step-by-step procedure to create Dockerfile, custom images and deploy containers to behave as virtual hosts
$ mkdir -p nginx-image; //create fresh directory
$ cd nginx-image/ //open the location
$ touch Dockerfile //creates new Dockerfile
$ vim Dockerfile //opens it using vim editor
You can copy a base image and make changes to it as required.
Here we are copying the base image from ubuntu:trusty distribution
$ FROM ubuntu:trusty //copies base image
$ RUN apt-get update && apt-get install -y iperf3
$ RUN apt-get install -y tcpdump && mv /usr/sbin/tcpdump /usr/bin/tcpdump
$ RUN apt-get install -y hping3
$ sudo docker build -t endpoint:latest
- This creates an image named "endpoint" using Dockerfile.
- Navigate to the directory where Dockerfile is located before executing this command.
$ sudo docker run -d --privileged --name=int --net=none endpoint:latest tail -f /dev/null
- Creates docker container named "int" which is your virtual host.
- Create as many hosts as you want by changing name.
- Disable default (docker) networking using "--net=none". this is because we are builing out own network.
- Container should run with "priveleged" flag to allow running of system calls by guest
- "-d" flag makes the container run as a daemon
- Container needs to be alive for the duration of the experiment so make it do something useless like monitoring the contents of an empty file keeping it alive forever
The above command will create a container, but it will keep running in the docker server if not stopped.
You also cannot create another container with the same name.
docker container ls -a
This gives a list of all existing containers with their container_id, image, names and status.
docker container stop f5a94c143c2a
Here, syntax is [container_id] instead of f5a94c143c2a
docker container rm f5a94c143c2a