Coder Social home page Coder Social logo

docker-sh's Introduction

Deprecated

this project predates docker compose, most of the use cases are already covered by docker compose

I'm no longer maintaining this project

Docker utility script

This is simple POSIX script for managing docker container, just like docker-compose for single container, but more powerful.

Because this is POSIX shell script, the possibility is limitless.

This approach is inspired by openrc from gentoo, ebuild from gentoo, PKGBUILD from archlinux, and APKBUILD from alpine.

This script is written with POSIX shell standard, so it will work with bash, ash, dash or any shell that follow POSIX standard.

How to install

To install in default location (/usr/local/bin/docker.sh)

curl -sSLf https://raw.githubusercontent.com/win-t/docker-sh/master/install.sh | sudo sh

or to custom location, e.g. /opt/bin/docker.sh

curl -sSLf https://raw.githubusercontent.com/win-t/docker-sh/master/install.sh | sudo sh -s - /opt/bin/docker.sh

How to use it

docker.sh will be used as interpreter, you need to install it in your PATH e.g. by copy docker.sh file to /usr/local/bin (install.sh will do this for you)

see full documentation for more.

Getting Started

Lets say you want to start wordpress project, using mariadb as database.

mkdir my-project
cd my-project

we need to create two spec file, unlike docker-compose, one spec file is used to control one container, so we need to create two files

create file wordpress with following content:

#!/usr/bin/env docker.sh

name=wordpress
image=wordpress:latest
net=net-wordpress
opts="
  -p 8080:80
  -v wordpress-data:/var/www/html
  -e WORDPRESS_DB_HOST=mariadb
  -e WORDPRESS_DB_PASSWORD=password
"

create file mariadb with following content:

#!/usr/bin/env docker.sh

name=mariadb
image=mariadb:latest
net=net-wordpress
opts="
  -v mariadb-data:/var/lib/mysql
  -e MYSQL_ROOT_PASSWORD=password
"

Please note that wordpress and mariadb must have same net value so each container can communicate

then, make those two file executable by running

chmod +x wordpress mariadb

and start the the container by running:

./mariadb start
./wordpress start

and done. You can access wordpress on http://localhost:8080

Use it with ansible

We also provide ansible module for this script, see inside ansible_module directory.

TODO

  • Automated testing

docker-sh's People

Contributors

win-t 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.