Closed fishandsheep closed 3 months ago
You want to use docker exec
not docker run
to run keydb-cli
inside your running container.
$ docker run --rm --name mycontainername -p 6381:6379 -d eqalpha/keydb
10cdd9cc34d672c75b39c094924e1f3c889b25973696d6b55ab8452daeddbae3
$ docker run --rm --name mycontainername1 -p 6379:6379 -d eqalpha/keydb
0c236966c2daade388e21380dc3e34f49795d1d3779c3e9f48a3edf8b6923a18
Running instances:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c236966c2da eqalpha/keydb "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp mycontainername1
10cdd9cc34d6 eqalpha/keydb "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:6381->6379/tcp, :::6381->6379/tcp mycontainername
And connecting to them:
$ keydb-cli -p 6381 info|grep run_id
run_id:f9a30f414e526625622a94de5fd6500c4b3d10b9
$ docker exec -it mycontainername keydb-cli info|grep run_id
run_id:f9a30f414e526625622a94de5fd6500c4b3d10b9
$ keydb-cli -p 6379 info|grep run_id
run_id:dc9d0470fe9302c7891a188aa7a73c45a3d002c6
$ docker exec -it mycontainername1 keydb-cli info|grep run_id
run_id:dc9d0470fe9302c7891a188aa7a73c45a3d002c6
I see. It's true that I don't fully understand docker yet , docker run eqalpha/keydb keydb-cli
connects to port 6379 inside the container, or i can connect directly without specifying a port,
[root@10-7-154-170 ~]# docker run -it --rm eqalpha/keydb keydb-cli -h 172.17.0.2 -a mypassword
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
Message of the day:
KeyDB has now joined Snap! See the announcement at: https://docs.keydb.dev/news
172.17.0.2:6379> set port 6381
OK
[root@10-7-154-170 ~]# keydb-cli -p 6381 -a mypassword
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
Message of the day:
KeyDB has now joined Snap! See the announcement at: https://docs.keydb.dev/news
127.0.0.1:6381> get port
"6381"
I have two keydb docker container , one is bound to port 6379 and the other to 6381
The container bind to 6379 can be connected normally via docker keydb-cli
But the other one can't be connected.
I can connect fine using the local client directly
I've tried several other ports and they refuse to connect. I'm not sure if I'm using docker in a bad way or not. HELP :cry::cry::cry: