Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Docker 🐳

Basic Dockerfile commands:

FROM          - Add
MAINTAINER    - Entrypoint
LABEL         - Volume
RUN           - User
CMD           - Workdir
EXPOSE        - On Build
ENV
COPY

Useful commands:

docker build -t image-name path\to\image              - Builds the Image
docker run image-name                                 - Runs the Image
docker image ls                                       - Lists all Images
docker container ls -a                                - Lists all Containers

Container Management

docker run -p 8080:80 SERVICE
               *port

docker container logs -f CONTAINER_ID

docker start OR stop CONTAINER_ID                    - Starts or stops the Container
docker exec -it CONTAINER_ID /bin/bash               - Executes the Container

Image Management

docker pull REGISTRY/IMAGE:TAG                       - Pulls your image from Docker Hub
              *usually your user and image tag

docker push image-name                               - Pushes your image to Docker Hub

Creating a recursive DNS server with Docker

docker run -it --name srv-dns -p 53:53/udp -p 53:53/tcp ubuntu        - Port 53 is the default one for DNS [!]

Linux will automatically start after that, so we'll keep going on the container ambient:

apt-get update
apt-get install bind9 bind9utils dnsutils vim -y                      - NVIM is better btw
cd /etc/bind                                                          - Main folder for bind's configuration files

Tip

We'll start our configs through named.conf.options

vim named.conf.options

options {
        // defines the production folder for the server
        directory "/var/cache/bind";

        // will allow any server to make queries on our server
        allow-query{
                any;
        };

        // those are our forwarders
        forwarders {
                8.8.8.8;
        };

        // this lil' bro will add an extra layer of security, the dnssec
        // basically, it'll verify the user's digital signatures
        dnssec-validation auto;

        // this will define which ipv6 interfaces the server's going to hear
        listen-on-v6 { any; };
};

Note

After that config, we can already start bind, we'll use the following commands:

service named status                                                  - Just checking bind's status
service named start                                                   - Will fail if named.config isn't correctly configured

Creating and configuring zones

And also creating an authoritative DNS server, lmao


Warning

We'll keep going on the same linux instance, so no need to create a new one if you don't want to.

vim named.conf.local
// here we'll define the name of the domain we're creating
zone "lab.local"{
        type master; // tells that this server has the official copy of this zone

        file "/etc/bind/db.lab.local"; // path to the file that holds the IP registers
};

Then, we'll create our new file, db.lab.local:

vim db.lab.local
$TTL 604800
@       IN      SOA     ns1.lab.local. admin.lab.local. ( ; SOA will define that this bro is the authoritative guy
                        2026020901      ; Serial (file's version)
                        64800           ; Refresh time the slave takes to ask for changes to the master
                        86400           ; Retry (Time the slave waits to ask again in case the master is a jerk and doesn't answer)
                        2419200         ; Expire (Time the slave keeps answering before also shutting down with the master)
                        604800 )        ; Negative Cache TLL (Time for the other servers to decide "This domain doesn't exists")


; Here we're doing the translations (name to IP, IP to name)
@       IN      NS      ns1.lab.local.
ns1     IN      A       172.16.0.2
www     IN      A       172.16.0.100
ftp     IN      A       172.16.0.200

Note

As of now, our Authoritative server is configured!

We'll now test our config with the command named-checkzone lab.local /etc/bind/db.lab.local

service named restart                                  - Just restarting the server
dig @localhost www.lab.local                           - We can change the 'www' to 'ns1' or 'ftp', this will point out to a different address

We've made the server translate from name to IP, now we'll do the opposite!

vim named.conf.local

We'll add this to the file:

// in-addr.arpa is the sufix used to tell that this server does the inverse search
zone "0.17.172.in-addr.arpa"{
        type master;

        file "/etc/bind/db.172.17";
};

Let's now create the file db.172.17

vim db.172.17
$TTL    604800
@       IN      SOA     ns1.lab.local. admin.lab.local. (
                        2026021001      ; Serial
                        64800           ; Refresh
                        86400           ; Retry
                        2419200         ; Expire
                        604800          ; Negative Cache
                        )

; This mf will indicate that this is IP to name
@       IN      NS      ns1.lab.local.
2       IN      PTR     ns1.lab.local.
100     IN      PTR     www.lab.local.
200     IN      PTR     ftp.lab.local.

We'll test out our file with named-checkzone 17.172.in-addr-arpa db.172.17

dig @localhost 172.17.0.2                              - Or .100 or .200

About

How to make a DNS Server running with Docker? This tutorial can help you!

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages