Docker – Building an Image – my-bind

Reading Time: < 1 minute

Last Update: 2/16/2025

This post centers around creating and maintaining a local image. In this case we will build an image based on ubuntu and install BIND9 on it. We will keep the networking simple so that it’s easy to install.

The chief advantage we get over building our own image is that we also get the chance to control and preposition items on it. So good news there. As we add more PACKAGES the image is obviously going to get bigger. There are also going to be more components we should consider from a security standpoint.

FROM ubuntu
MAINTAINER test-user
RUN apt update
RUN apt install vim -y
RUN apt install bind9 iproute2 bind9utils dnsutils iputils-ping -y
EXPOSE 53/tcp
EXPOSE 53/udp
USER bind:bind
CMD ["/usr/sbin/named", "-f"]

now we can build the image

docker build -t my-bind .

A docker-compose.yaml file that uses the “my-bind” image

services:
  my-bind:
    image: my-bind
    ports:
      - "53:53/udp"
      - "53:53/tcp"
    networks:
      - my-bind-net
networks:
  my-bind-net:
    driver: bridge

Now we can launch the image

docker compose up -d

We can “shell” into the running image

docker exec -it 3333 /bin/bash
root@nodey:~/x5# docker image ls -a
REPOSITORY              TAG          IMAGE ID       CREATED          SIZE
my-bind                 latest       56dffca9200a   15 seconds ago   246MB
phpmyadmin/phpmyadmin   latest       0276a66ce322   3 weeks ago      571MB
mysql                   latest       3e34946bc4c4   3 weeks ago      797MB
php                     8.2-apache   6797f9b5ce56   8 weeks ago      502MB
ubuntu/bind9            latest       5210e5bddb6a   5 months ago     168MB
sudo systemctl disable systemd-resolved
sudo systemctl stop systemd-resolved
docker compose up -d
root@nodey:~/x5# docker network ls
NETWORK ID     NAME            DRIVER    SCOPE
636dba43d889   bridge          bridge    local
6cd60b8fa7add   host            host      local
be3a385a293f   none            null      local
89f77d7986cb   x5_my-bind-net   bridge    local
root@nodey:~/x5# docker network inspect x5_my-bind-net | grep IPv4Address
                "IPv4Address": "172.23.0.2/16",

This entry was posted in Docker. Bookmark the permalink.