ix-ai/swarm-launcher

Volume ?

duchnoun opened this issue · 3 comments

Hi,

Can we mount local volume ? (i don't have found how to) => not with files/dir mapping.

example :

services:
pcs:
image: ixdotai/swarm-launcher:latest
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:rw'
environment:
LAUNCH_IMAGE: master:5000/pcs:latest
LAUNCH_HOST_NETWORK: 'true'
LAUNCH_PULL: 'true'
LAUNCH_PROJECT_NAME: 'pcs'
LAUNCH_SERVICE_NAME: 'pcs-service'
LAUNCH_CONTAINER_NAME: 'pcs-container'
LAUNCH_PRIVILEGED: 'true'
LAUNCH_VOLUMES: 'pcsd:/var/lib/pcsd'
LAUNCH_CAP_ADD: 'ALL'
LAUNCH_DEVICES: '/dev/xvdb:/dev/xvdb'
LAUNCH_ENVIRONMENTS: 'PASSWORD=ratata38'

volumes:
pcsd:


when i do that , error : service "pcs-service" refers to undefined volume pcsd: invalid compose project :(

Thanks

Auto response (i don't know if its good solution) , if you have idea..


version: '3.2'

services:
pcs:
image: ixdotai/swarm-launcher:latest
volumes:
- '/var/run/docker.sock:/var/run/docker.sock:rw'
- pcsd:/mount/pcsd
environment:
LAUNCH_IMAGE: master:5000/pcs:latest
LAUNCH_HOST_NETWORK: 'true'
LAUNCH_PULL: 'true'
LAUNCH_PROJECT_NAME: 'pcs'
LAUNCH_SERVICE_NAME: 'pcs-service'
LAUNCH_CONTAINER_NAME: 'pcs-container'
LAUNCH_PRIVILEGED: 'true'
LAUNCH_VOLUMES: '/mount/pcsd:/var/lib/pcsd'
LAUNCH_CAP_ADD: 'ALL'
LAUNCH_DEVICES: '/dev/xvdb:/dev/xvdb'
LAUNCH_ENVIRONMENTS: 'PASSWORD=ratata38'

volumes:
pcsd:

tlex commented

Alright, there is quite a bit to unpack here.

First, to format everything properly, since for YAML the number of spaces at the beginning of the line are important, please use three backticks ``` before and after your code.

Next: the volume defined by volumes isn't the same as /mount/pcds (second example), nor does it get created with the name pcsd (first example).

I normally don't use volumes, but I use bind mounts (what you have in the second example - it tries to mount the folder /mount/pcsd from the host inside the docker container under /var/lib/pcsd). Also, the swarm-launcher has no reason to access the volume itself (so, the line - pcsd:/mount/pcsd) since it connects via the docker socket to the host underneath and the host itself will start the container.

Now, to get it to work, the easiest way is:

  • ensure you have a folder on the host called /mount/pcsd)
  • use the following:
version: '3.2'

services:
  pcs-launcher:
    image: ixdotai/swarm-launcher:latest
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:rw'
    environment:
      LAUNCH_IMAGE: master:5000/pcs:latest
      LAUNCH_HOST_NETWORK: 'true'
      LAUNCH_PULL: 'true'
      LAUNCH_PROJECT_NAME: 'pcs'
      LAUNCH_SERVICE_NAME: 'pcs-service'
      LAUNCH_CONTAINER_NAME: 'pcs-container'
      LAUNCH_PRIVILEGED: 'true'
      LAUNCH_VOLUMES: '/mount/pcsd:/var/lib/pcsd'
      LAUNCH_CAP_ADD: 'ALL'
      LAUNCH_DEVICES: '/dev/xvdb:/dev/xvdb'
      LAUNCH_ENVIRONMENTS: 'PASSWORD=ratata38'

You will maybe notice that I've changed the name of the service as well - this is just to make sure there are no overlaps with the LAUNCH_PROJECT_NAME (even though there shouldn't be)

tlex commented

Please don't forget that the containers started by swarm-launcher do not run in swarm mode. It's only running docker compose underneath (you can check out the script: https://github.com/ix-ai/swarm-launcher/blob/master/entrypoint.sh).

So, unless your DNS on the host knows who master is, pulling that image will not work (master:5000/pcs:latest). You must use LAUNCH_NETWORKS to attach it to an existing docker swarm network, for it to be able to resolve any service called master that runs in your docker swarm.