Error while using docker run - linux

I'm new to using Docker and I am trying to follow a tutorial on this link which requires using a Docker. I have successfully installed the Docker on Ubuntu with the Docker docs tutorial.
I am following Option A and have completed steps 1,2, and 3. For 3 I had to precede the statement by sudo in order to get it work. However, when I try to run step 4 using the command docker run -it -p 8888:8888 -v <path to repo>:/root mlatberkeley/showandtell, I get the following error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint eager_pasteur (fb195057d626924#####################3d3d6f24071497fc443fbd8c9): Error starting userland proxy: listen tcp 0.0.0.0:8888: bind: address already in use.
I have hashed some of the string of numbers above in the output error. I am new to Docker and I would be grateful for some suggestion to resolve the error.

There seems to be another process that is binded on port 8888.
To find this process run the command sudo netstat -tulpn | grep :8888. This will show you the process pid in the last column.
This might be a docker container that you have started previously. In that case try to remove the container by running docker container ls and then docker container rm -f <container-name-from-prev-command>. You can also start the new container on a new port, by replacing 8888:8888 with 9999:8888.

Related

What can I do when bind: adress already in use?

When I want to run my network with hyperledger fabric v. 2 and couchdb I get following error for all couchdb and ppeers:
WARNING: Host is already in use by another container
ERROR: for ca_peerOrg1 Cannot start service ca0: driver failed programming external connectivity on endpoint ca_peerOrg1 (e1ebe2f0cbdbddf0a1873a3db798e21ecd9aa5bac1944eb522bddaedabc87eba): Error starting userland proxy: listen tcp 0.0.0.0:7054: bind: address already in use
Creating ca_peerOrg2 ... error
What I have done so far, but wasn't helping:
docker rm -f $(docker ps -a -q)
Then I wanted to stop docker compose, by follwoing command:
docker-compose stop
But I got some errors, and actually I installed docker compose before.
Then I removed the images and installed them again with the commands:
I am always working in the same project. Just starting it sometimes again, to solve some errors.
I do not understand, how I can all bring down and up again.
For starting my network I use following command:
sudo ./start_Network.sh
If I want to use sudo ./start_Network.sh down is not working.
What can I do to solve my errors?

How do I connect a docker container to tor proxy on local machine?

I want to ping a website from inside my docker container through tor proxy on my local machine. Without setting the proxy, I could not be able to ping. When I run my container with:
sudo docker run --rm -it -p9150:9150 my-container
I got the following error:
Error starting userland proxy: listen tcp 0.0.0.0:9150: bind: address already in use.
I started tor-browser on my localhost:9150 but I can't do port-forwarding when running a container. Also I don't want to use --net=host in command. I added the following line
Environment="ALL_PROXY=socks5://127.0.0.1:9150" to /lib/systemd/system/docker.service but it didn't word. Anyone can help me with this? (OS: Ubuntu 20.04)
To run the TOR proxy and the app
After a long research I did, I came up to the following steps:
sudo docker pull dperson/torproxy
sudo docker network create tor
sudo docker run --rm -it --name mytor --network tor -p9050:9050 dperson/torproxy
sudo docker run --rm -it --network tor myapp
Inside myapp I have a python script which sends message to my telegram channel through tor socks proxy. I have a network (tor) and both containers see each other through it. In the python script I have the following line:
bot = telegram.Bot(token=token, request=Request(con_pool_size=10, connect_timeout=40, proxy_url='socks5h://mytor:9050'))
To manually test the TOR proxy
Run another container, a general-purpose one like for example
docker run --rm -it --network tor ubuntu:22.04
Install curl the usual way (for example with apt-getin debian/ubuntu).
Then inside the command line do:
curl -x socks5://mytor:9050 http://checkip.amazonaws.com/
You'll see the IP of the TOR exit node:

Running Splash on Docker Toolbox with Windows 10

I am trying to install and run splash on using Windows 10 Home. I have installed docker toolbox, as on windows 10 Home you can't install docker. Then in command prompt when I type
docker pull scrapinghub/splash
I get the error
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.40/images/create?fromImage=scrapinghub%2Fsplash&tag=latest: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
One interesting thing I noticed was that if I run Docker Quickstart Terminal I can install splash with the command
docker pull scrapinghub/splash
and then using the command
docker run -p 5023:5023 -p 8050:8050 -p 8051:8051 scrapinghub/splash
it gives me
server listening on http://0.0.0.0:8050
But then when I paste http://0.0.0.0:8050 into Chrome it gives me "This site can't be reached."
Thanks
So 1st error clearly says that your Docker container is not running, so your pull command fails
You can check by running any docker command maybe try this
docker --version
For your 2nd query, you need to use Docker IP, to access the application
You can try docker-machine ip to see, on what IP docker is running (Assuming docker-machine is installed)
Generally, on windows Docker IP is 192.168.99.100
Try these 2
192.168.99.100:8050
or
localhost:8050

Error response from daemon: driver failed programming external connectivity on endpoint modest_aryabhata

I'm going through this tutorial
making docker image with: docker build -t myapp_back .
and then want to run container with: docker run -p 3000:3000 -d myapp_back
it's simlpe node/express app
But I'm getting an error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error
response from daemon: driver failed programming external connectivity
on endpoint wizardly_wescoff
(a7c53e0d168f915f900e3d67ec72805c2f8e4f5e595f6ae3c7fed8e097886a8b):
Error starting userland proxy: mkdir
/port/tcp:0.0.0.0:3000:tcp:172.17.0.2:3000: input/output error.
What's wrong?
my dockerfile:
FROM node:carbon
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ['npm', 'start']
and start in package.json:
"start": "nodemon src/app.js --exec babel-node"
To solve the following error in Windows: just Restart Docker (from tray menu or selecting the 'Restart Docker...' option in Settings/Reset)
Cannot start service YOUR_SERVICE: driver failed programming external connectivity on endpoint ...
Looks like it is a known issue from docker: https://github.com/docker/for-win/issues/573
Try:
disabling "Experimental Features" in the Settings/Daemon menu
restarting docker
stopping all containers.
To stop all containers, run: docker ps -a -q | ForEach { docker stop $_ }
EDIT: Working ShellScript code to Stop All Containers
for a in `docker ps -a -q`
do
echo "Stopping container - $a"
docker stop $a
done
Just restarted my computer and it works now..
I am able to get docker working on my windows 10 pc by resetting docker to the factory defaults. Restarting docker, restarting my machine did not work.
On Mac Mojave, run the following command to find which processes are using the port.
sudo lsof -i #localhost:<port_no>
In my case I was checking port 8080 so I run
sudo lsof -i #localhost:8080
I found that the http-alt is running on port 8080 and after getting the process id using above command you can kill the processes by
sudo kill -9 <process_id>
However, in my case four applications ArtemisSe, Mail, Google and Slack are using http-alt on port 8080. Since they look important applications so I changed my port and run the container on 8888 instead of 8080. i.e.
docker run -it --rm -p 8888:8080 <imageid or image name>
Restarting the computer is not the actual fix, just a workaround, that one would need to be doing on a frequent basis.
The problem is related with the default windows 10 shutdown behaviour.
The actual fix can be achieved disabling windows fast startup settings:
Control Panel -> Power Options -> Choose what the power button does -> Change settings that are currently unavailable -> Toggle Turn on fast startup
I am running under linux. If I run docker as root with the sudo command, it works fine.
Just restart docker, right click on its icon then restart. that solved my problem
In my case, the same error in PHP Container. I solve changing the public port and works.
This command throw error after restart my Windows 10:
docker run -d -p 8080:80 --name php_apache php_app
Solution:
docker run -d -p 8081:80 --name php_apache php_app
Just run this command to stop your all containers
It worked for me.
for a in docker ps -a -q
do
echo "Stopping container - $a"
docker stop $a
done
In some case,restarting your computers solve problem. But it is not really best solution, especially UNIX like operation system.
First of all you should know other process is either running or not in specific port, If you see such port is already in use by other resources. you should kill that procees which running in that port. To do that just follow:
sudo lsof -i #localhost:<port number>
Output looks like this
Command PID USER TYPE SIZE ...
<command> <pid number>
We need pid number which is defines procees id
And then kill that process by its procees id
sudo kill -9 <pid>
After kill that procees you can run your new container in such port as you want

Can't access from outside process running in a Docker container

I'm trying to run a gameserver inside a docker container on my server but I'm having troubles connecting to it.
I created my container and started my gameserver (which is using port 7777) inside it.
I'm running the container with this command:
docker run -p 7777:7777 -v /home/gameserver/:/home -c=1024 -m=1024m -d --name my_gameserver game
I published the ports 7777 with the -p parameter but I can't connect to my gameserver, even though logs show that it is started.
I think I should bind my IP in some way but I have no idea what to do.
What I found so far is that docker inspect my_gameserver | grep IPAddress returns 172.17.0.24.
The problem was coming from the fact that I didn't expose the UDP port.
Correct command was:
docker run -p 7777:7777 -p 7777:7777/udp -v -d --name my_gameserver game

Resources