Shell in a swarm container

I cannot connect to a container that runs on a swarm. It seems that the following does not work:

docker exec -it <container_ID> bash

Here are some results:

>$ 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 ran:

$ docker exec -it 2jk3s2xs7ce62piunbkiptypz bash

or

$ docker exec -it login.1 bash

and see the following errors

The answer to the error from the daemon: there is no such container: 2jk3s2xs7ce62piunbkiptypz

The error response from the daemon: there is no such container: login.1

+4
source share
1 answer

Use docker psto find names that you can use. Look under CONTAINER IDand NAMESwill either 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
root@e53bff8bebfc:/#

The long name has the form $SERVICE_NAME.$REPLICA_NUMBER.$ID_FROM_SERVICE_PS

>$ docker exec -it login.1.cg7fltcu3wfe7ixtnqzg8myy1 bash
root@e53bff8bebfc:/#
+7
source

Source: https://habr.com/ru/post/1657323/


All Articles