Skip to content

puncoz-official/dock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dock: Docker Helper Script

Table of Contents

Introduction

dock is a Docker Helper Script that simplifies the management of Docker containers and provides convenience functions for working with Docker Compose, SSL certificates, and SSH access within containers.

Prerequisites

Before using Dock, ensure you have the following prerequisites installed on your system:

Installation

Follow these steps to install and configure Dock on your system:

  1. Clone the Dock repository to your local machine:

    git clone https://github.com/puncoz-official/dock.git
  2. Copy the env.example file and update it with your desired configuration:

    cp env.example .env
    # Edit the .env file with your configurations
  3. [Optional] For convenience, add the ./dock script to your system's PATH. On macOS or Linux, you can do this by adding the following line to your shell profile (e.g., ~/.bashrc, ~/.zshrc):

    export PATH="$PATH:/path/to/dock"

    On Windows, you can add the directory containing dock to your system's environment PATH.

  4. Apply SSL certificates by running the following command:

    dock certs:apply
  5. Start the Docker Compose application by running:

    # to start all services
    dock up
    
    # to start specific services 
    dock up <service1-name> <service2-name>

Usage

Dock provides several commands to manage your Docker environment.

Certificate Commands

Generate and manage SSL certificates for your domains.

  • Generate Certificates for Domains:

    dock certs [-n cert_name] [-d domain_name_1] [-d domain_name_2] ...

    Example:

    dock certs -n my_app -d "my-app.localhost" -d "*.my-app.localhost"
  • Apply Generated Certificates:

    dock certs:apply

docker-compose Commands

Manage Docker Compose services.

  • Start the Application (Runs in the Background):

    dock up
  • Stop the Application:

    dock down
  • Supports All Docker-Compose Commands:

    dock [commands]
    
    # eg:
    dock ps

SSH Commands

Access shell sessions within Docker containers.

  • Start a Shell Session within the Application Container (as Root User):

    dock ssh <service-name>
  • Start a Shell Session within the Application Container (as a User Supplied):

    dock ssh user@<service-name>

Examples

Here are some common usage examples of Dock:

  • Generate SSL certificates for a domain:

    dock certs -n my_app -d "my-app.localhost" -d "*.my-app.localhost"
  • Apply SSL certificates:

    dock certs:apply
  • Start the Docker Compose application:

    dock up
  • Stop the Docker Compose application:

    dock down
  • Access a shell session within the application container as the root user:

    dock ssh <service-name>
  • Access a shell session within the application container as a specific user:

    dock ssh user@<service-name>

Tips

MySQL Grants

If you encounter an "Access denied for user 'root'@'localhost'" issue with MySQL 5.7, follow these steps before creating a database:

Run the following command (replace 'password' with your desired password) before creating the database. If the database is already created, drop the database and recreate it after running this command:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

SSL Certificates for HTTPS

To generate SSL certificates for HTTPS, follow these steps:

  1. Install mkcert:

    # If it's the first install of mkcert, run
    mkcert -install
  2. Generate a certificate for your domain and store it in the certs directory:

    mkcert -cert-file ./data/certs/local-cert.pem -key-file ./data/certs/local-key.pem "localhost" "subdomain.localhost"

    This will create two files: local-cert.pem and local-key.pem in the certs directory, which can be used for configuring HTTPS in your application.

Contributing

Contributions to dock are welcome! If you have any suggestions, bug reports, or feature requests, please create an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Docker helper script

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 89.7%
  • Dockerfile 10.3%