I have the following docker container
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y curl net-tools netcat nmap
CMD /bin/bash
I run it with volume /tmp
mapped
From host, I created a socket inside /tmp
. I tested with ncat
and the connection works from host. However, it does not work from the docker container.
ncat -U /tmp/uwsgi.sock
Ncat: Connection refused.
How could I achieve this?
Permissions:
$ ls -al /tmp/uwsgi.sock
srwxrwxrwx 1 user wheel 0 Jun 19 23:53 /tmp/uwsgi.sock
Ncat: Connection refused.
means peer side has close the connection, so you in container cannot link to it.
One example for you:
docker host part:
shubuntu1@shubuntu1:~$ ncat -lU /tmp/test.sock
hello
world
command to lunch container with another ssh session:
shubuntu1@shubuntu1:~$ docker run -it -v /tmp:/tmp ubuntu /bin/bash
container part:
root@01f724409cec:/# apt-get update && apt-get install -y curl net-tools netcat nmap
root@01f724409cec:/# ncat -U /tmp/test.sock
hello
world
You can see on any side when you input hello
, world
, another side could see it too.
But if close the unix socket on docker host side:
shubuntu1@shubuntu1:~$ ncat -lU /tmp/test.sock
hello
world
^C
shubuntu1@shubuntu1:~$
Then again connect it in container side:
root@01f724409cec:/# ncat -U /tmp/test.sock
hello
world
^C
root@01f724409cec:/# ncat -U /tmp/test.sock
Ncat: Connection refused.
It will show Connection refuesd
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.