Code Monkey home page Code Monkey logo

test_container's Introduction

Docker Nginx Entrypoint Script

This repository contains a simple bash script entrypoint.sh designed to be the entrypoint for a Docker container running Nginx. This script is intentionally straightforward and offers a foundation for learning Docker and Kubernetes patterns, which can be expanded upon to cover different use cases.

How it Works

The script starts an Nginx process in the background. It then gets the process ID of this process and enters into a while loop, where it checks various environment variables that could influence the behaviour of the script. Depending on the value of these environment variables, it performs different actions such as simulating a failure, changing the background color of the webpage or creating a ready file after some time.

Finally, it kills the original Nginx process and starts a new one. This is done to keep the shell open, unless it crashes.

Additional features are planned for the near future. A guide on how to set the appropriate enviornment variables will also be included.

How to Use

This script is designed to work with a Dockerfile that sets it as the entrypoint.

This Dockerfile performs the following actions:

  1. Uses the latest version of the Nginx image.
  2. Sets the working directory in the container.
  3. Copies your web files from your local directory (./html/) into the appropriate directory in the container.
  4. Copies the entrypoint script into the /opt/ directory in the container.
  5. Makes the entrypoint script executable.
  6. Sets the entrypoint script as the entrypoint for the container.

The Docker container can be built and run using standard Docker commands. Once the container is running, the behaviour can be influenced using the environment variables mentioned in the script.

Disclaimer

Remember, this script is a learning tool and is intentionally simplified to facilitate understanding. Always consider the requirements and constraints of your actual use case when developing production-ready scripts and Dockerfiles.

test_container's People

Contributors

mlmerchant avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.