Shell into swarm container

I’m unable to connect to a container that’s running on a swarm. Seems like the following doesn’t work:

docker exec -it <container_ID> bash

Here is some output:

  • How import file from computer to docker containers with mongodb
  • kubernetes replication controller
  • How to delete an inherit property from yaml config?
  • Unable to preserve install state in docker container
  • How to run Linux Docker images on Windows Server 2016?
  • Docker Entrypoint for Postgres 9.3
  • >$ docker service ls
    ID            NAME          REPLICAS  IMAGE                              COMMAND
    4rliefwe74o5  login         1/1       login-arm64:1.0
    >$ docker service ps login
    ID                         NAME     IMAGE                       NODE               DESIRED STATE  CURRENT STATE          ERROR
    2jk3s2xs7ce62piunbkiptypz  login.1  login-arm64:1.0  odroid64-cluster4  Running        Running 5 minutes ago

    Then I’ll run:

    $ docker exec -it 2jk3s2xs7ce62piunbkiptypz bash


    $ docker exec -it login.1 bash

    and see the following errors

    Error response from daemon: No such container: 2jk3s2xs7ce62piunbkiptypz

    Error response from daemon: No such container: login.1

  • Can't run sonar-scanner inside docker container: Permission denied
  • docker run a shell script in the background without exiting the container
  • Using Docker via windows console: includes invalid characters for a local volume name
  • Trying to run Docker resulted in exit code 127
  • Installing openssh-server, g++, gdb, and gdbserver in a docker container | Visual C++ for Linux Development + Docker
  • Docker on Mac: Can't view ports
  • One Solution collect form web for “Shell into swarm container”

    Use docker ps to find the names you can use. Look under both CONTAINER ID and NAMES, either will work.

    >$ docker ps
    CONTAINER ID        IMAGE             COMMAND                  CREATED             STATUS              PORTS               NAMES
    e53bff8bebfc        login-arm64:1.0   "/bin/sh -c 'node ser"   27 seconds ago      Up 25 seconds                           login.1.cg7fltcu3wfe7ixtnqzg8myy1
    >$ docker exec -it e53bff8bebfc bash

    The long name is of the form $SERVICE_NAME.$REPLICA_NUMBER.$ID_FROM_SERVICE_PS

    >$ docker exec -it login.1.cg7fltcu3wfe7ixtnqzg8myy1 bash
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.