Install (Kali)

sudo apt install docker.io

Image Related

# Listing local images
docker image ls
# Remove Image
docker image rm <image_name>

# Running image
# -it: interactive
docker run -it <image_name> /bin/bash

Container Related

# List running containers
docker ps
# List all containers
docker ps -a

Flags for Run

Flag Description
-d Detach mode (run in background)
-it Interactive and run a shell within container
-v <volume> Specify a volume to mount
-p <host_port>:<container_port> Expose a host port to the container port
–rm <container> Remove container once it finishes running
–name <container> Assign a name to container

Building container

Docker Files

Instructions Description
FROM <image> Setting base image
RUN <command> Run command in container with new layer
COPY <directory> Copy local file to working directory in container
WORKDIR <directory> Set working directory of container
CMD <command> Run command when the container starts (for starting services)
EXPOSE <port> Tell the user to expose the port