4

Hello i am trying to issue commands to a Redis docker container. The container is up and running.I have used the following command: docker run -d -p 8300:85 -t redis

enter image description here

However when i try to use from my terminal: redis-cli -p 8300 nothing happens.
It just looks that it is waiting for something.

enter image description here

How can i communicate to my redis container; what am i doing wrong?

P.S After i have set the redis port to the defualt 6379 i get an id as response when using docker run but it still stops right there(first image):

enter image description here

From another terminal (second image) you can see that while the first terminal is blocked ,the instance is created but not started.

P.S 2 After waiting for like 10 minutes i finally get an error message when running the redis container:

$ docker run -d -p 8300:6379 -t redis
244d898dcfb0cd1da4828ee99a16bdd12f62499f99e8dc3ee17af9bacefe5b41
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: failed to create endpoint upbeat_blackwell on network nat: HNS failed with error : You were not connected because a duplicate name exists on the network. If joining a domain, go to System in Control Panel to change the computer name and try again. If joining a workgroup, choose another workgroup name.
Bercovici Adrian
  • 8,794
  • 17
  • 73
  • 152

1 Answers1

8

It looks like you're publishing the wrong port with docker. Looking at your first screenshot you can see port 6379 (default redis) is not published to your host, but port 85 is published on port 8300.

Change your run command to docker run -d -p 8300:6379 -t redis and see if that helps.

As an alternative you can execute redis-cli from your running container docker exec -it a425 redis-cli (a425 is your container ID from the first screenshot). In this case you don't need anything installed on your host machine.

Mikael Kjær
  • 670
  • 3
  • 6
  • But i wanted it to be set at port `85` inside the container.Why would it set it to `6379` ? – Bercovici Adrian Sep 20 '18 at 07:38
  • Ok now after i have set the port to `6379` i get an `id` as a response but it still stops there after that.From another terminal i can see that the instance `STATUS` is `CREATED` but it isn't running.I have updated my post . – Bercovici Adrian Sep 20 '18 at 07:42
  • That sounds like another question/problem to me. Why are you adding the -t redis in the end? Did you follow some guide? – Mikael Kjær Sep 20 '18 at 07:52
  • I thought it is necessary.If you think this is a separate question , ok i will post it elsewhere..but i stil can't run the `redis-cli` at the end of the day. – Bercovici Adrian Sep 20 '18 at 07:57
  • 1
    I see no mention of `-t redis` on the [redis docker image documentation](https://hub.docker.com/_/redis/) so try without that, but since it started without it the first time I doubt that's the issue. You could try to delete the redis container, restart your docker daemon and try again if it's just a test environment. – Mikael Kjær Sep 20 '18 at 08:01
  • I updated my initial post.After waiting it out i finally got an error message. – Bercovici Adrian Sep 20 '18 at 08:16
  • 1
    I think [this](https://stackoverflow.com/questions/38070837/windows-container-failed-to-start-with-error-failed-to-create-endpoint-on-netw) explains your second problem. – Mikael Kjær Sep 20 '18 at 08:22
  • It can be closed.The image worked.I thought it was blocked but it worked. – Bercovici Adrian Sep 20 '18 at 10:57