This is an old revision of the document!


In order to connect to docker, you should firstly know the name of the docker container. This can be obtained as follows:

[root@tain-cx-uatdkrdb1 ~]# docker container ls
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS               NAMES
71e7c7016763        docker-registry.tain.com/cassandra:3.10   "/docker-entrypoint.…"   9 days ago          Up 9 days                               cas3
ea9b9f22c874        docker-registry.tain.com/cassandra:3.10   "/docker-entrypoint.…"   9 days ago          Up 9 days                               cas2
46fac822cffe        docker-registry.tain.com/cassandra:3.10   "/docker-entrypoint.…"   9 days ago          Up 9 days                               cas1

So in order to connect we can simply execute the /bin/bash on the container:

[root@tain-cx-uatdkrdb1 ~]# docker exec --help

Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container

Options:
  -d, --detach               Detached mode: run command in the background
      --detach-keys string   Override the key sequence for detaching a container
  -e, --env list             Set environment variables
  -i, --interactive          Keep STDIN open even if not attached
      --privileged           Give extended privileges to the command
  -t, --tty                  Allocate a pseudo-TTY
  -u, --user string          Username or UID (format: <name|uid>[:<group|gid>])
  -w, --workdir string       Working directory inside the container
[root@tain-cx-uatdkrdb1 ~]# docker exec -it cas1 /bin/bash
root@46fac822cffe:/#    <- We are on 1st container :) 

  • docker_management.1571396697.txt.gz
  • Last modified: 2019/10/18 20:04
  • (external edit)