Search code examples
ubuntudockerportbinddaemon

Correct way to start docker daemon listening to specific port


I´m new to docker and want to start it in daemon mode listening to a specific IP-adress and port. In the documentation it is said that this can be done by writing sudo /usr/bin/docker daemon -H 0.0.0.0:5555. It then says that I can list running containers with this command docker ps. If I try this I get the following message:

Get http:///var/run/docker.sock/v1.20/containers/json?all=1: dial unix /var/run/docker.sock: no such file or directory.

  • Are you trying to connect to a TLS-enabled daemon without TLS?
  • Is your docker daemon up and running?

I cannot interact with it. I´ve searched for a solution but with no luck. Any suggestions?

P.S. How can I run this daemon in background? I tried appending an & but I´m stuck on the ouput till pressing ctrl+c.

Thanks in advance


Solution

  • I found a solution to my problem. I specified docker running on IP x and Port y, but docker then only listens to that socket. I had to add another -H flag with the unix socket in order to listen to local requests:

    sudo /usr/bin/docker daemon -H tcp://0.0.0.0:5555 -H unix:///var/run/docker.sock