Search code examples
dockeransibledocker-composedocker-swarmdocker-stack

can I use ansible to start docker swarm services without compose?


how can I ssh into a service created by docker swarm? I have created a service using docker stack and the yaml file looks like this:

version: '3'
services:
  app:
    image: "myimage1"
    expose:
      - "8080"

and I validated that the service is running but I'm not sure how to ssh into the service(container) that was created.


Solution

  • To ssh into container, you would need ssh service running inside container. This is generally not a good practice. To get access to container shell without having ssh running, you can use: docker exec -ti bash/sh

    Ansible has docker modules for managing containers and images(http://docs.ansible.com/ansible/docker_container_module.html#docker-container, http://docs.ansible.com/ansible/docker_image_module.html#docker-image)