A Dockerfile is a text file that contains a set of instructions used to automate the creation of a Docker image. It defines the environment, software dependencies, configurations, and commands that will be executed inside a container when it is built and run. Dockerfiles are used by Docker to build images, which can then be used to create containers.
Here's a breakdown of common Dockerfile instructions:
- FROM: Specifies the base image to use (e.g.,
FROM ubuntu:20.04
). - RUN: Executes commands inside the image, such as installing software packages (e.g.,
RUN apt-get update
). - COPY: Copies files or directories from your local filesystem to the image (e.g.,
COPY . /app
). - ADD: Similar to
COPY
, but can also handle URLs and unpack compressed files. - WORKDIR: Sets the working directory for subsequent instructions (e.g.,
WORKDIR /app
). - CMD: Specifies the default command to run when a container is started (e.g.,
CMD ["python", "app.py"]
). - EXPOSE: Informs Docker that the container will listen on specific ports (e.g.,
EXPOSE 80
). - ENV: Sets environment variables in the container (e.g.,
ENV APP_ENV=production
). - ENTRYPOINT: Defines the command that will always run when the container starts, even if a different command is provided at runtime.
- VOLUME: Creates a mount point for volumes, allowing data persistence (e.g.,
VOLUME /data
).
# Use the official Python image as the base image
FROM python:3.8-slim
# Set the working directory in the container
WORKDIR /app
# Copy the current directory contents into the container
COPY . /app
# Install any necessary dependencies
RUN pip install -r requirements.txt
# Expose port 5000
EXPOSE 5000
# Define the default command to run the app
CMD ["python", "app.py"]
- Reproducibility: The same Dockerfile can be used to build the same environment across different systems, ensuring consistency.
- Automation: A Dockerfile allows you to automate the process of building an image with specific configurations and software.
- Portability: Once built, Docker images can be shared and run on any platform that supports Docker.
In essence, a Dockerfile is a blueprint for creating Docker images, ensuring the environment is consistent and reproducible.
Snigdha OS is a minimal operating system designed to run in Docker containers. It is a lightweight, open-source solution for users looking to leverage SnigdhaOS within Docker environments. This repository provides the necessary files to build and run SnigdhaOS containers.
- Lightweight and minimal: Optimized for Docker environments with minimal resource usage.
- Customizable: Tailor the OS to your needs by modifying configurations and adding your own tools.
- Docker-ready: Pre-configured Dockerfile for easy deployment in containerized environments.
Before you start, make sure you have the following installed on your local machine:
- Docker: Install Docker
- Git: Install Git
To get started with SnigdhaOS Docker, first, clone this repository to your local machine:
git clone https://github.com/Snigdha-OS/snigdhaos-docker.git
cd snigdhaos-docker
Once you have cloned the repository, you can build the Docker image using the Dockerfile provided:
docker build -t snigdhaos:latest .
This command will create a Docker image named snigdhaos
tagged with latest
.
After building the Docker image, you can run SnigdhaOS in a container:
docker run -it snigdhaos:latest
This will start a new Docker container and open an interactive terminal session with SnigdhaOS running inside it.
If you'd like to run SnigdhaOS with Docker Compose for easier management, you can use the provided docker-compose.yml
file. To start the container with Docker Compose, run:
docker-compose up -d
This will launch the container in the background. To stop the container, run:
docker-compose down
You can customize SnigdhaOS for your use case by modifying the Dockerfile or by extending it with additional tools and libraries. After making changes, rebuild the image using the command:
docker build -t snigdhaos:latest .
Contributions are welcome! If you'd like to improve SnigdhaOS Docker, feel free to fork the repository and submit a pull request with your changes.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes and create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Docker: For providing an easy-to-use containerization platform.
- SnigdhaOS: For the core OS functionalities that can be containerized.
This project is maintained by Eshan Roy | eshanized.