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
On Ubuntu (16.04 LTS) with docker-ce (17.03.1~ce-0~ubuntu-xenial
) do the following to make docker listen to a TCP port instead of sockets.
Add a file /etc/systemd/system/docker.service.d/override.conf
with the following content:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
Add a file /etc/docker/daemon.json
with the following content
{
"hosts": [
"tcp://127.0.0.1:2375"
]
}
Reload (systemctl daemon-reload
) and restart (systemctl restart docker.service
) docker.
For reference: https://github.com/moby/moby/issues/25471
EDIT:
Be careful, so the demon will only listen to that network port ignoring local requests. To make docker listen to both remote and local, edit daemon.json but keep the standard unix socket
{
"hosts" : [
"unix:///var/run/docker.sock",
"tcp://<docker-host-ip-or-localhost>:2375"
]
}
Docker daemon connection options docs
On Mac OSX you'd run the Docker Quickstart Terminal App to see:
Machine default already exists in VirtualBox.
Starting machine default...
Started machines may have new IP addresses. You may need to re-run the `docker-machine env` command.
Setting environment variables for machine default...
...
## .
## ## ## ==
## ## ## ## ## ===
/"""""""""""""""""\___/ ===
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
\______ o __/
\ \ __/
\____\_______/
docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com
now
docker ps
should work
On Linux e.g. Ubuntu prepending sudo might be necessary. E.g.
docker ps
will lead to:
Get http:///var/run/docker.sock/v1.20/containers/json: dial unix /var/run/docker.sock: permission denied.
* Are you trying to connect to a TLS-enabled daemon without TLS?
* Is your docker daemon up and running?
but
sudo docker ps
will work.
See https://docs.docker.com/articles/basics/
To check if your docker service is running you can call
sudo service --status-all 2>&1 | grep docker
and it should show:
[ - ] docker
Sometimes your docker instllation might be corrupt see: Docker daemon does not start or restart
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With