Skip to main content

Simplify the usage of containers

Project description

Sugar

CI Python Versions Package Version License Discord

Simplify the usage of containers.

You may be thinking, why do I need a new library that wrap-up docker-compose or podman-compose if they are already really simple to use?

Yes, they are simple to use, but if you have some other parameters to the compose command line, it could be very tedious to write them every time such as --env-file, --project-name, --file, etc.

So, in this case we could use something like a script or make, right?

Yes, and just for one project it would be good enough. But, if you maintain or collaborate a bunch of projects, it would be like a boiler plate.

Additionally, if you are maintaining some extra scripts in order to improve your containers stack, these scripts would be like a boilerplate as well.

So, the idea of this project is to organize your stack of containers, gathering some useful scripts and keeping this information centralized in a configuration file. So the command line would be very simple.

How to Install

$ pip install containers-sugar

Features

The commands from docker-compose available are:

  • build
  • config
  • create
  • down
  • events
  • exec
  • images
  • kill
  • logs
  • pause
  • port
  • ps
  • pull
  • push
  • restart
  • rm
  • run
  • start
  • stop
  • top
  • unpause
  • up
  • version

These commands are available in the main profile/plugin, so you don't need to specify any extra parameter to access them.

For extra commands, we are gathering them into a profile/plugin called ext, so you can access them using something like: sugar compose-ext restart.

The current available ext commands are:

  • start -> alias for up
  • restart -> runs stop and up

How to use it

First you need to place the config file .sugar.yaml in the root of your project. This is an example of a configuration file:

backend: compose
defaults:
  profile: ${{ env.ENV }}
profiles:
  profile1:
    project-name: project1
    config-path:
      - containers/tests/profile1/compose.yaml
    env-file: .env
    services:
      default:
        - service1
        - service3
      available:
        - name: service1
        - name: service2
        - name: service3
  profile2:
    project-name: null
    config-path: containers/tests/profile2/compose.yaml
    env-file: .env
    services:
      available:
        - name: service1
        - name: service3

Some examples of how to use it:

  • build the defaults services (service1,service3) for profile1: sugar build --profile profile1

  • build the all services (there is no default service defined) for profile2: sugar build --profile profile2

  • build all services (ignore default) for profile1: sugar build --profile profile1 --all

  • start the default services for profile1: sugar compose-ext start --profile profile1

  • restart all services (ignore defaults) for profile1: sugar compose-ext restart --profile profile1 --all

  • restart service1 and service2 for profile1: sugar compose-ext restart --profile profile1 --services service1,service2

NOTE: If you use: default: profile: ${{ env.ENV }}, you don't need to give --profile <PROFILE_NAME>, except if you want a different profile than the default one.

Podman Extension (Experimental)

Sugar now includes experimental support for Podman through the podman-ext extension. This extension allows you to use Podman as a container engine backend instead of Docker, with both standard container operations and experimental commands.

Key Features

See the Podman Extension documentation for detailed usage instructions and configuration options.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

containers_sugar-1.19.2.tar.gz (42.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

containers_sugar-1.19.2-py3-none-any.whl (54.0 kB view details)

Uploaded Python 3

File details

Details for the file containers_sugar-1.19.2.tar.gz.

File metadata

  • Download URL: containers_sugar-1.19.2.tar.gz
  • Upload date:
  • Size: 42.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure

File hashes

Hashes for containers_sugar-1.19.2.tar.gz
Algorithm Hash digest
SHA256 7992205686233380a0434ae51c99a8b771d036932295b3eab1f5c8f3a24585ab
MD5 1ad50175ca3a742bebbb24b8d332431e
BLAKE2b-256 39bfed040bb4d5e23f1d9640fce4989da5d010357e7239649abe2ec47cad8691

See more details on using hashes here.

File details

Details for the file containers_sugar-1.19.2-py3-none-any.whl.

File metadata

  • Download URL: containers_sugar-1.19.2-py3-none-any.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.10.18 Linux/6.11.0-1018-azure

File hashes

Hashes for containers_sugar-1.19.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e11c11e4f2e3a779dbf10798b41d5ffc4677e35cb4a650f5584a8be59757390e
MD5 d67c39c715430f243f758d5a11988e44
BLAKE2b-256 8d52cd4decc988628ffac59e453661707f4f466eae6178249ddcd707569934c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page