oxker icon indicating copy to clipboard operation
oxker copied to clipboard

[NEW FEATURE] Docker swarm support

Open AtomBaf opened this issue 1 year ago • 7 comments

Describe the solution you'd like Docker swarm support to monitor services and manage them like a container.

Describe alternatives you've considered As an alternative I'm currently using web-based tools like like swarmpit or portainer.

AtomBaf avatar Nov 05 '24 06:11 AtomBaf

I've not setup/used a Docker Swarm before, would you be able to provide a simple example configuration?

mrjackwills avatar Nov 05 '24 13:11 mrjackwills

Here as a sample configuration.

version: "3.3"

services:
  database_service:
    image: mysql:5.7
    volumes:
      - db_data_volume:/var/lib/mysql
    networks:
      internal_network:
        aliases:
          - database_alias
    ports:
      - "3308:3306"
    deploy:
      placement:
        constraints:
          - node.labels.database == true
      replicas: 1
      restart_policy:
        condition: any
    environment:
      MYSQL_DATABASE: app_database_name
      MYSQL_USER: app_db_user
      MYSQL_PASSWORD_FILE: /run/secrets/db_password_secret
      MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db_root_password_secret
    command:
      [
        --character-set-server=utf8,
        --collation-server=utf8_general_ci,
        --sql-mode=STRICT_TRANS_TABLES,
      ]
    secrets:
      - db_password_secret
      - db_root_password_secret

  app_service:
    image: app_image:latest
    volumes:
      - app_documents_volume:/documents
    networks:
      internal_network:
        aliases:
          - app_service_alias
      external_network:
        aliases:
          - app_external_alias
    deploy:
      placement:
        constraints:
          - node.labels.application == true
      replicas: 1
      restart_policy:
        condition: any
    configs:
     - source: app_config_file
       target: /path/to/config.properties
     - source: app_persistence_file
       target: /path/to/persistence.properties

networks:
  internal_network:
  external_network:
    external: true

secrets:
  db_password_secret:
    external: true
  db_root_password_secret:
    external: true

configs:
   app_config_file:
     file: ../config.properties
   app_persistence_file:
     file: ../persistence.properties

volumes:
  db_data_volume:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /path/to/db_data_directory
  app_documents_volume:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /path/to/documents_directory

its similiar to compose, but have some features to be used in production.

Here is a script to setup a project locally:

#!/bin/sh

IP_ADDRESS=$(ip -4 addr show scope global | grep inet | awk '{print $2}' | cut -d/ -f1 | head -n 1)

if [ -z "$IP_ADDRESS" ]; then
    echo "Error: Was not possible to obtain the IP address."
    exit 1
fi

echo "Initializing Docker Swarm with IP: $IP_ADDRESS..."
docker swarm init --advertise-addr "$IP_ADDRESS" || echo "Swarm already initialized."


echo "Creating networks..."
docker network create -d overlay database || echo "Network 'database' already exists"
docker network create -d overlay my-network || echo "Network 'my-network' already exists"

echo "Creating secrets..."
echo "passwork" | docker secret create db_password_secret -
echo "rootpass" | docker secret create db_root_password_secret -

echo "Deploying stack..."
docker stack deploy -c compose-dev.yml my-stack

echo "Process completed!"

waiting for this feature!

eliseucbrito avatar Nov 26 '24 19:11 eliseucbrito

waiting for this feature!

Don't hold your breathe, but I'll have a look into it

mrjackwills avatar Nov 26 '24 20:11 mrjackwills

Docker swarm support to monitor services and manage them like a container.

I have a basic service set up, I've not used Docker swarm before, what features do you think would be essential to implement into oxker in order to manage the swarm? Secondly, what information about the swarm (or each replica?) would be essential to display?

mrjackwills avatar Dec 04 '24 12:12 mrjackwills

Taking swarmpit as en example, I would like to see all services, and zooming into one of them would allow me to see its parameters, replicas, status....

AtomBaf avatar Dec 04 '24 20:12 AtomBaf

what features do you think would be essential to implement into oxker in order to manage the swarm

  1. show all stacks running
  2. can enter on a stack and see what services is running
  3. can enter on a service and show logs
  4. same features for containers (start, stop, restart, delete)

It would also be cool to see other docker things like:

  • volumes
  • configs (config files)
  • networks
  • secrets (the names)
  • nodes

eliseucbrito avatar Dec 07 '24 13:12 eliseucbrito

Maybe have a look at lazydocker, which supports at least compose files as "services".

palto42 avatar Mar 09 '25 18:03 palto42