Docker Community Forums

Share and learn in the Docker community.

Error connecting to docker container

HI,

I installed a service on a remote Linux computer using docker. I used the following commands

  • git clone https://github.com/OpenVidu/openvidu-tutorials.git

  • npm install -g http-server

  • http-server openvidu-tutorials/openvidu-getaroom/web

  • docker run -p 4443:4443 --rm -e openvidu.secret=MY_SECRET -e openvidu.publicurl=https://187.84.228.66:4443 openvidu/openvidu-server-kms

But when I try do connect the first time, I receive the follow error menssage: “ERR_EMPTY_RESPONSE”. sometime “ERR_CONNECTION_CLOSED”

I used the following diagnostic command in Linx computer “docker ps” and received the following response:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
21b0620266cd openvidu/openvidu-server-kms:latest "/usr/bin/supervisor 5 days ago Up 5 days 8443/tcp, 8888/tcp, 0.0.0.0:4443->4443/tcp, 9091/tcp sick_ritchie

What is wrong? How can I solve this?

If anyone can help me, I’m grateful.

Fernando

2 Likes

hello,
up vote
22
down vote
accepted
You need to publish the exposed ports by using the following options:

-P (upper case) or --publish-all that will tell Docker to use random ports from your host and map them to the exposed container’s ports.

-p (lower case) or --publish= that will tell Docker to use ports you manually set and map them to the exposed container’s ports.

The second option is preferred because you already know which ports are mapped. If you use the first option then you will need to call docker inspect demo and check which random ports are being used from your host at the Ports section.

Just run the following command:

docker run -it -p 8080:8080 demo
After that your url will wor
best regards
craig

Hi Craig

Thank you very much from the informations.

But I have one doubt:.

Using the command = docker run -it -p 8080: 8080 demo

What is demo?

The demo means the service is running?

If yes, the correct command is = docker run -it -p 8080: 8080 openvidu/openvidu-server-kms**:2.1.0**

Kind regards,

Fernando

Hi ,

I try to run

docker run -it --net host --pid host --cap-add audit_control
-e DOCKER_CONTENT_TRUST=$DOCKER_CONTENT_TRUST
-v /var/lib:/var/lib
-v /var/run/docker.sock:/var/run/docker.sock
-v /usr/lib/systemd:/usr/lib/systemd
-v /etc:/etc --label docker_bench_security
docker/docker-bench-security

but the output is

Error connecting to docker daemon (does docker ps work?)

docker version is : Docker version 1.11.1, build 5604cbe
Linux version : (Red Hat 4.8.5-4)

I have a system with Docker version 1.10.3, build 20f81dd and container run properly…

It seems that this is related with docker version ? Could you Please help?

Thank you
BR,
George

Hi, could you include the docker version from the host you’re running the docker/docker-bench-security container on?
There is issues when different versions of Docker is trying to communicate with each other, do you get the same results when running the standalone script?

Thanks & Regards

Yes! johnson987 I’m totally agreed with you.
Any other suggestion?

You need to publish the exposed ports by using the following options:

-P (upper case) or --publish-all that will tell Docker to use random ports from your host and map them to the exposed container’s ports.

-p (lower case) or --publish=[] that will tell Docker to use ports you manually set and map them to the exposed container’s ports.

The second option is preferred because you already know which ports are mapped. If you use the first option then you will need to call docker inspect demo and check which random ports are being used from your host at the Ports section.

Just run the following command:

docker run -it -p 8080:8080 demo
After that your url will work.

Hello there,
I was facing the same problem since last week. Bee reading multiple articles and solutions but non of them worked. But finally, your solution has helped me solve the problem.
Regards,