Sign inSign up

comanderanch/dind-builder

By comanderanch

Updated over 1 year ago

Image
0

111

comanderanch/dind-builder repository overview

comanderanch/dind-builder

A Docker-in-Docker (DinD) image based on Ubuntu 22.04 that includes Docker, Nginx, Supervisord, Docker Compose, and Nano. This image is preconfigured with a static Nginx test page and supports persistent volume mounting for configuration and static content. It is ideal for testing volume mounts, learning about persistent configurations, and serves as a base for building more complex Docker-in-Docker environments.

Features

  • Docker-in-Docker: Run Docker commands inside the container.
  • Nginx Reverse Proxy: Nginx is installed and configured to serve a static test page.
  • Persistent Volumes: Supports host volume mounting for:
    • Nginx configuration: /etc/nginx/nginx.conf
    • Static web content: /usr/share/nginx/html
  • Supervisor Process Manager: Manages Nginx and other services.
  • Docker Compose & Nano Installed: For further customization and development.

Getting Started

Default Usage (Without Host Overrides)

If you simply pull and run the image, it will use the built-in defaults. Anonymous volumes will be created for configuration and content, containing the static test page.

docker run -d --privileged --name dind-container -p 80:80 -p 2376:2375 comanderanch/dind-builder

Visit http://<host-ip>/ in your browser to see the Nginx test page.

Running with Host-Mounted Volumes
To easily customize the Nginx configuration and static content, create a directory structure on your host. For example:

mkdir -p /home/youruser/dind-project/vm/config
mkdir -p /home/youruser/dind-project/vm/html

Create your custom files:

Custom Nginx Configuration
Create the file /home/youruser/dind-project/vm/config/nginx.conf with the following content:

_______________________________________

events {}

http {
    server {
        listen 80;
        server_name _;

        location / {
            root /usr/share/nginx/html;
            index index.html;
        }
    }
}

__________________________________________

Custom Static Page
Create the file /home/youruser/dind-project/vm/html/index.html with the following content:

_________________________________________


<!DOCTYPE html>
<html>
<head>
    <title>DinD Custom Test Page</title>
</head>
<body>
    <h1>Hello from a customized Nginx in DinD!</h1>
    <p>This static page is served from a host-mounted volume.</p>
</body>
</html>


__________________________________________

Run the Container with Volume Mappings
___________________________________________



docker run -d --privileged --name dind-container \
  -p 80:80 -p 2376:2375 \
  -v /home/youruser/dind-project/vm/config/nginx.conf:/etc/nginx/nginx.conf:ro \
  -v /home/youruser/dind-project/vm/html:/usr/share/nginx/html \
  comanderanch/dind-builder

_____________________________________________


Now, any changes you make to the files in /home/youruser/dind-project/vm/ will be reflected inside the container. Visit http://<host-ip>/ to see your custom static page.



Customization & Next Steps
Adding Services:
You can extend this image by adding a Docker Compose stack inside the container to run services like WordPress, MySQL, Grafana, etc. Update the Nginx configuration accordingly to act as a reverse proxy.

Persistent Data:
Use host-mounted volumes to persist application data (e.g., databases) so that your data remains even if the container is recreated.

Debugging & Logs:
Check Nginx logs inside the container (e.g., /var/log/nginx.err.log) and use docker logs dind-container for overall container logs.

License
This project is open source and available under the MIT License.

Happy Dockering! Feel free to fork this image and customize it to fit your needs.

sincerely,
[email protected]



---

You can include this `README.md` in your repository and update it as your image evolves. This will help users understand how to use the image, mount volumes for persistence, and how to extend it for more complex setups!

Summary for the README
Note on Persistence:
The Docker-in-Docker (DinD) environment uses an ephemeral filesystem by default. This means that if the container is removed or recreated, any files (including your Docker Compose files stored in /root/dind-stack) will be lost unless they are persisted using a bind mount or named volume.

To persist your Compose files:
You can bind mount a host directory (e.g., /home/comanderanch/dind-project/dind-stack) to /root/dind-stack in the container. This ensures that even if the container is removed, your Compose file and associated scripts remain on the host and can be reattached to a new container.

If you do not use a bind mount, you'll need to recreate your Docker Compose file inside the container each time you rebuild or restart it. This setup is acceptable for development and testing, but for production or long-term use, using persistent volumes or bind mounts is recommended.

Tag summary

Content type

Image

Digest

sha256:3c69b24ca

Size

206.1 MB

Last updated

over 1 year ago

docker pull comanderanch/dind-builder