Cheat Sheet Hacking
  • 🌐Generic Ideas
    • File Transfer
    • Reverse Shell
    • Cracking Tricks
    • Tunneling and Port Forwarding
    • Reversing
    • OSINT
    • Phishing
  • 🐕‍🦺Port enumeration
    • Reconnaissance
    • 53 - DNS
    • 80,443 - Web
      • Identify php.ini file used
      • Exploitation
        • File Upload
        • XXS
    • 445 - SMB
    • 389, 636, 3268 - LDAP(S)
  • LINUX THINGS
    • Enumeration
    • Privilege Escalation
      • Writable $PATH
  • WINDOWS THINGS
    • Enumeration
    • Useful Commands
    • Active Directory Methodology
      • Commands to create AD environment
      • Attacks
        • Kerberos
          • User enumeration
          • ASREP-Roast
          • Kerberoasting
          • ASREP-Roast VS Kerberoasting
          • Golden Ticket
          • Resource Based Constrained Delegation
        • Secrets dump
        • Pass The Hash
        • Dump NTDS
        • Tickets
          • TGT
        • NTML Password Spray
        • LDAP Authentication
          • LDAP Pass-back
          • Rogue LDAP Server
        • SMB Relay (LLNMR, NTB-NS & WPAD)
        • NTLM Relay
        • Tools to exploit AD things
        • SCF Files
      • Kerberos
      • SAM & LSA secrets
      • Enumeration
        • BloodHound
        • PowerView
          • CheatSheet of Commands
        • Set DNS & DOMAIN
      • Resources
      • RunAs
      • Post Explotation
        • Persistence
        • Mimikatz
      • Common used tools
  • 🕳️Pivoting
    • Port Forwarding
    • Socks Forwarding
    • Routing
    • Web Fuzzing
    • Transfer files
    • Metasploit
      • Single Pivot
      • Double Pivot
    • Burp Suite
  • 🎛️Hardware
    • Physical attacks
  • 🌕Buffer Overflow
    • Introduction
    • Stack-Based
      • Introduction
        • Spiking
        • Fuzzing
        • Find Offset
        • Overwrite EIP
        • Find module
        • Find Badchars
        • Shellcode
  • 🐳Docker
    • Commands
    • Practical examples
  • 💡Useful things
    • Burp Suite
      • Proxy Activation
    • Linux Commands
    • Recreate multipart/form-data request
      • Python
      • HTML & netcat
    • TTY
    • Templates for reports (exams)
    • Tmux
    • Other cheat sheets
Powered by GitBook
On this page
  • List all the images
  • Download image
  • Delete image
  • Create a container with the image
  • With random container name
  • With custom container name
  • Start a container
  • Using the ID of the container
  • Using the custom name of the container
  • Using environment variables
  • Status of containers running
  • Stop a container
  • List of containers started and off
  • Delete a container
  • Expose a container in a host port
  • Custom port
  • Random port
  • Check logs of container
  • Download the image, create and start the container
  • With logs view, random data
  • Without logs view, detach mode and random data
  • Without logs view and custom data
  • Interact with networks
  • List networks
  • Create a network
  • Delete a network
  1. Docker

Commands

PreviousShellcodeNextPractical examples

Last updated 5 months ago

List all the images

docker images

Download image

# docker pull [image]
docker pull mysql

Delete image

# docker image rm [image]
# docker image rm [image]:[tag]
docker image rm mysql
docker image rm mysql:latest
docker image rm mysql:16

Create a container with the image

With random container name

It will generate an ID to the container.

# docker container create [image]
# docker create [image]
docker create mysql

Id generated:

a6e16354239fc76b4cc89216bfe46f0260500a7e798d62e319af213345bb13c8

With custom container name

docker create --name monguito mongo

Id generated:

e1d70ca8719dcf07987eae76bac9a621d4531e9c9b8bdf8328b647e649d3f438

Start a container

Using the ID of the container

# docker start [container_id]
docker start a6e16354239fc76b4cc89216bfe46f0260500a7e798d62e319af213345bb13c8

Using the custom name of the container

docker start monguito
docker ps # we will see the container running

Using environment variables

For example, to create a mongodb container with specific user and password, to then use an app to connect to it, we use the env variable described in mongodb hub:

Each image has different ways to configure

docker create -p27017:27017 --name monguito -e MONGO_INITDB_ROOT_USERNAME=nico -e MONGO_INITDB_ROOT_PASSWORD=password mongo

Status of containers running

docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS       NAMES
a6e16354239f   mysql     "docker-entrypoint.s…"   4 minutes ago   Up 2 seconds   27017/tcp   pedantic_rubin

Stop a container

docker stop a6e16354239f
docker ps
# There is no one container running

List of containers started and off

List all the containers in system.

docker ps --all
docker ps -a
CONTAINER ID   IMAGE     COMMAND                  CREATED        STATUS                    PORTS     NAMES
a6e16354239f   mysql     "docker-entrypoint.s…"   22 hours ago   Exited (0) 22 hours ago             pedantic_rubin

Delete a container

Using name

docker rm pedantic_rubin
docker ps -a #container deleted

Expose a container in a host port

Custom port

# docker create -p[port_in_host]:[port_in_container] --name [name] [image]
docker create -p27017:27017 --name monguito mongo
docker start monguito
docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                           NAMES
6c97203a3708   mongo     "docker-entrypoint.s…"   2 minutes ago   Up 2 seconds   0.0.0.0:27017->27017/tcp, :::27017->27017/tcp   monguito

Random port

# docker create -p[port_in_container] --name [name] [image]
docker create -p27017 --name manguito mongo
docker start manguito
docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS                                           NAMES
2bdec62e384c   mongo     "docker-entrypoint.s…"   6 seconds ago   Up 1 second    0.0.0.0:32768->27017/tcp, :::32768->27017/tcp   manguito

Check logs of container

docker logs monguito

Or to stay watching those logs:

docker logs --follow monguito

Download the image, create and start the container

With logs view, random data

docker run mongo

Without logs view, detach mode and random data

docker run -d mongo
Unable to find image 'mongo:latest' locally
latest: Pulling from library/mongo
57c139bbda7e: Pull complete 
2a7c884ecb1c: Pull complete 
ddcbc3e219f6: Pull complete 
347abad2978b: Pull complete 
33ad7d6a71b8: Pull complete 
46b764746687: Pull complete 
0d22e1cb5ef2: Pull complete 
fef1dc21c099: Pull complete 
Digest: sha256:175ee5c400f24d2766cea492b4986851b4e7ec75fc08e354673149b86488019c
Status: Downloaded newer image for mongo:latest
309059638da6dc66af6cd40312bef60c36b1b7b6056bc6b3f38d824ab39b2e26

It generates our container ID:

309059638da6dc66af6cd40312bef60c36b1b7b6056bc6b3f38d824ab39b2e26
docker ps          
CONTAINER ID   IMAGE     COMMAND                  CREATED              STATUS              PORTS       NAMES
309059638da6   mongo     "docker-entrypoint.s…"   About a minute ago   Up About a minute   27017/tcp   crazy_thompson

Without logs view and custom data

docker run -d --name monguito -p27017:27017 mongo
#a146ef22b6bb96889a273d8037f4613eefb5519e063faa8f84555e1fb43072e8
docker ps                                        
CONTAINER ID   IMAGE     COMMAND                  CREATED              STATUS              PORTS                                           NAMES
a146ef22b6bb   mongo     "docker-entrypoint.s…"   About a minute ago   Up About a minute   0.0.0.0:27017->27017/tcp, :::27017->27017/tcp   monguito

Interact with networks

List networks

docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
b17449f934b1   bridge    bridge    local
6b89bd5bc050   host      host      local
fdc75e667bd0   none      null      local

Create a network

# docker network create [nombre]
docker network create mired
NETWORK ID     NAME      DRIVER    SCOPE
b17449f934b1   bridge    bridge    local
6b89bd5bc050   host      host      local
9cbcc9aa1f95   mired     bridge    local
fdc75e667bd0   none      null      local

Delete a network

docker network rm mired

🐳
https://hub.docker.com/
https://hub.docker.com/_/mongo