I am trying to run azuracast on docker with ubuntu [duplicate] - docker

This question already has answers here:
Docker - Bind for 0.0.0.0:4000 failed: port is already allocated
(26 answers)
Closed 18 days ago.
I am facing this error. Error response from daemon:
driver failed programming external connectivity on endpoint azuracast (921386c2563e5e74537acd9f8b3aaf1f982cb974d9af4d24387382d2771d9a12): Bind for 0.0.0.0:80 failed: port is already allocated
I dont know what to do
I am trying to run azuracast on docker. The container is running without any port.

from the error port is already allocated means that you have another service on your machine using port 80.
To figure out what is using port 80 use netstat -tulpn | grep :80
you can also, change the port of the new docker container to run on a different port, by passing something like -p 8080:80 to the docker run command.

Related

How to Connect Docker Container to localhost [duplicate]

This question already has answers here:
Exposing a port on a live Docker container
(16 answers)
Closed yesterday.
I've created a docker container with ubuntu image. In that I've created a react app and when I try to run the app I could not see the app is running on localhost but in the terminal of container it says its running on the port. How can we connect a docker container with our localhost.
If You have a docker file just pass the port to docker run with -p
3001:3000
If you have a docker compose set the port with:
ports:
- 3001:3000
and run docker-compose up -d
Finally navigate to localhost:{Port}
From official documentation : docker run -p 127.0.0.1:80:8080/tcp ubuntu bash
This binds port 8080 of the container to TCP port 80 on 127.0.0.1 of the host machine. You can also specify udp and sctp ports. The Docker User Guide explains in detail how to manipulate ports in Docker.
Then docker ps and verify its running and ports are exposed.
Also check about your firewall, it may block ports.

docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use [duplicate]

This question already has answers here:
Docker Error bind: address already in use
(33 answers)
Closed last year.
I am new and trying out this tutorial from DigitalOcean but when I do docker run -p 5000:5000 flask_demo:v0, I am getting the following error.
docker:
Error response from daemon: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use.
Please help me
Then you just bind another port
docker run -p 5001:5000 flask_demo:v0
-p 5001:5000 basically means, bind port 5001 in my host machine with the port 5000 in the container. Since port 5000 already used in your host machine, then u can bind with another port example: port 5001
You probably ran the application once before. When a docker container exits, it's still on your machine and has the port allocated.
To see what containers you have, run the command
docker ps -a
You'll probably see your old container listed and that it's using port 5000.
Remove it with
docker rm <container name>
Now the port is available again.
If you don't think you'll need to look at your container after it exits, you can add the --rm parameter to the docker run command and it'll be automatically removed when it exits. Like this
docker run -p 5000:5000 --rm flask_demo:v0
First find what process is occupying the port:
ss -aultnp|grep 5000
Get the program: pid
ps -ef|grep pid
Find the program occupying the port

How to make docker container use port other than 80

I try to deploy self hosted Bitwarden service: https://bitwarden.com/help/article/install-on-premise/
When I run install script I get the following error:
docker: Error response from daemon: driver failed programming external connectivity
on endpoint certbot
(393789b88f2a15db0ae5fb0d3fdce83e14bd4d4eb890ffff0f946dc607953815): Error starting
userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use.
ERRO[0000] error waiting for container: context canceled
Which is expected because I already have NGINX on this VM with a couple of websites and port 80 is being used by the host.
I heard that is is possible to make docker container use another host port, instead of 80. That is container will have port 80, but it will be something else externally on the host. I tried to change the mapping in the install script like 5000:80 instead of 80:80 but I keep getting the same error.
Am I doing something wrong, or what I am trying to do is not possible?
You can add range to the command and it will use the first available port.
so -p 80-100:80.
TO get the port that your actually mapping to use docker ps and it will show you what port it's mapped to.

failed to initialize database, got error dial tcp 127.0.0.1:3306: connect: connection refused Problem

im learning docker and go now
but i got the problem when i docker run with this
docker run --rm -p 8080:8080/tcp --env-file .env my-project:latest
here are some of my .env code. i use docker desktop on windows, is it not possible to run docker on localhost in windows?
DB_HOST=127.0.0.1
DB_USERNAME=root
DB_NAME=mydbs
DB_PASS=root123
AUTH_GEN_URL=https://api.learning.mydbs.id
anyone have a clue? any answer would be appreciated
thank youu
The problem is that when you spin up the container it tries to connect to 127.0.0.1:3306 within the container and not the host, hence you are getting the error as connection refused since nothing is running on port 3306 at localhost in your container.
For Windows and Mac this can easily be fixed by using host.docker.internal instead of 127.0.0.1. This ensures that the service running inside your container correctly connects to the MySQL instance running on the host machine.
For Linux it's even more simple as all you have to do is pass --network="host" option to the docker run command

Connect a websocket client in a docker container to a websocket server in host

I have a websocket server running in my host, listening to port 8080.
In a docker container, I deployed a websocket client listening to the said server using this snippet:
connect_url="ws://0.0.0.0:80/"
and, exposing/mapping port 80 of the container to port 8080 of the host.
Dockerfile:
EXPOSE 80
When I ran the container:
docker run -p 8080:80 <name>
But I'm getting this error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint : Error starting userland proxy: Bind for 0.0.0.0:8080 failed: port is already allocated.
Now I think this error is because the server in the host is already using port 8080, that's why it can't be mapped.
With these details given, I just wanted to know how can my websocket client inside the docker container connect to the websocket server in the host.
I think problem is port 80 inside your container already in use, not 8080 on your host machine. Try to use another port for connect socket inside your docker container instead 80 (for example 777 port). Then run docker run -p 8080:777 <name>
By the way, check your host machine port already in user or not:
sudo lsof -i tcp:8080
If not thing show up, that mean port 8080 not yet used. Incase already in use. Kill that process on port 8080:
sudo kill -9 your_PID_ID
Then try again

Resources