Port Forwarding Failing For RabbitMQ in Docker - docker

I'm following the Docker documentation on https://docs.docker.com/samples/library/rabbitmq but when I get to port forwarding, I get the following error: C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint some-rabbit11 (c8065d91c990ad498501160011a7f264522ddb5f5a1188db934c47853f833fa2): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8080:tcp:172.17.0.2:15672: input/output error.
The command I'm trying to run from the terminal is docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 rabbitmq:3.6-management
From what I can find online, the command appears to be correct so I'm not sure what is the root cause.

Find out if any docker images use rabbitmq:
docker ps -a
Remove any images using docker rabbitmq:
docker rm <IMAGE ID>
Restart docker with the system tray app
Restart docker rabbitmq
docker run -d -p 15672:15672 -p 5672:5672 --name some-rabbit rabbitmq:3.6-management
The management console is exposed on port 15672 and rabbitmq on port 5672
Insure the new instance is running:
docker ps
Use the Firefox web-browser. This does not work in Google chrome. Browse to 127.0.0.1:5672
This cryptic code shows that rabbit is working.
Go to 127.0.0.1:15672 to view the management plugin in action.
The passwords are defaults.

Related

Cannot run RabbitMQ via Docker

What do I do wrong?
run as command
docker run -d --name rabbitmq_awr -p 5672:5672 -p 5673:5673 -p 15672:15672 rabbitmq:3-management
but http://localhost:15672/ didn't launch in browser
log below
First:
Make sure that your radditMQ instance is running by doing docker ps.
and if it is listed in the running containers.
Find out on which IP it is running on by using docker network inspect
Get that IP and launch it into your browser instead of localhost.
Second
If your container is not listed when you run docker ps, find out from the logs it issues using docker logs <container-name or id> whats causing the container to fail.

Docker windows Ports are not available:

New to Docker. I am running Visual Studio 2019 community on Win 10 machine. Installed Docker desktop and created two solutions (service1 and service2). I am trying to run both of the solutions on their own containers.
I was able to build and run service1 using:
docker run -it --rm -p 3000:80 --name mymicroservicecontainer mymicroservice
Question what is 3000:80? is 80 a port? because I was able to run my api using http://localhost:3000/api/product/1 from browser.
Next, I am trying to run service2 on it's own container by:
docker run -it --rm -p 2000:80 --name myanotherservicecontainer myanotherservice
Since the port is 2000, I guess it should work however I get following error:
docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:2000: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
time="2020-04-08T14:22:41-04:00" level=error msg="error waiting for container: context canceled"
Is that because I have :80 same as service1? What is the solution? I am running commands on admin mode in command prompt.
Please help. Thank you.
docker run -it --rm -p 3000:80 --name mymicroservicecontainer mymicroservice
Answer to your first question is YES, 80 is a port.
Basically what -p 3000:80 does is that it maps TCP port 80 in the container to port 3000 on the Docker host.
The error you are getting for services is because port 2000 is occupied some other process. It's clearly mentioned in the error message as well.
docker: Error response from daemon: Ports are not available
If you try to map it to some other port(that is free on your machine), then it would work as expected.
Maybe try -p 1111:80 or -p 1234:80
Read this for more detail on docker container networking.

Error starting userland proxy: Bind for 0.0.0.0:8080: unexpected error Permission denied

I am on windows 10 ent
Running command: docker container run -d -p 8080:80 --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
But I am getting this error:
docker: Error response from daemon: driver failed programming external connectivity on endpoint mysql(969f8eac66c92e42a4f19f6f28eec72c6802fea1eabed48dfb382c6a35cbb2ce)Error starting userland proxy: Bind for 0.0.0.0:8080: unexpected error Permission denied.
Need help.
This error is often caused because the port you specified is already in use. Sometimes it is because the current user does not have administrative rights.
If you do not specifically require port 80, try port 8000 or 8080.
docker container run -d -p 8080:8000 --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
If that doesn't fix it, try executing the command in sudo as some ports are system protected and require a user with admin privileges.
In all such cases where you are not sure which port is free on the host machine, you can try using -P option while running your images and then use docker port to see it's bind with which port.
#>docker container run -d -P --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
#>docker port mysql
3306/tcp -> 0.0.0.0:32768
docker#default:~$
After this you know which port is free then you can select that one and use your usual command.
#>docker container run -d -p 32768:80 --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
However I think, instead of 80 - you must expose 3306 port - since the default mysql doesn't provide a web-interface.
Adminer (formerly phpMinAdmin) is a different application that does provide mysql server embedded with it.

starting docker container with host mount to container

I am beginner and just started using docker, before posting here I google a lot but a lot of mixed confusing result.
I started docker with this command
docker run -itd --name dockWeb2 -v /var/www/wordpress/ -p 80:80 atozchevara/rpi-apache-php5
hoping I would be able to directly mount wordpress installation onto container , as by default it picks internal path of container /var/www/index.php, to override it I used -v flag. but it doesn't work.
I tried using multiple ports by passing -p arguments again for each port but that too gives error
docker run -itd --name dockWeb3 -v /var/www/wordpress/ -p 80:80 -p 22:22 atozchevara/rpi-apache-php5
66a959e4e99af8122705913005fcae12e2e8a5203da7b77ff1717751314fca28
docker: Error response from daemon: driver failed programming external connectivity on endpoint dockWeb3 (eb42a619a8c79961d35d59e0d8930a92541a20132525055afb3b0d2d87483e7f): Bind for 0.0.0.0:80 failed: port is already allocated.
otherwise Could have uploaded my wordpress using ssh to container's /var/www/ location.
For the first issue if you want to mount a volume from the host you need to use Bind mount a volume
docker run -itd --name dockWeb2 -v your_project_path:/var/www/wordpress/ 0.0.0.0:80 failed: port is already allocated. atozchevara/rpi-apache-php5
For the post using -p 80:80 you are publishing container port 80 to the host port 80, and if the host port is already in use you got an error 0.0.0.0:80 failed: port is already allocated. try to use a different port -p 9090:80.

trying to start an image in docker

I am trying to do this lab and type in the following command:
sudo docker run -it --name bdu_spark2 -P -p 4040:4040 -p 4041:4041 -p 8080:8080 -p 8081:8081 bigdatauniversity/spark2:latest /etc/bootstrap.sh -bash
But I get the following error. Is there a conflict between port 8080 of docker using it and other software trying to use it? I have restarted docker and made sure no other containers are running. Thanks for all the input.
Error response from daemon: Cannot start container 3c62472fe5f8481e5ee957550078f06106b45fc6bffe25669272e2ea924b5f36: failed to create endpoint bdu_spark2 on network bridge: Error starting userland proxy: listen tcp 0.0.0.0:8080: bind: address already in use
This is usually caused because another container is using 8080 port on your docker host.
You can see your running containers by running: $ sudo docker ps
Either stop the other container, or choose a different host port to map your container's 8080 to.
In my case doing this with MySQL, I didn't realize it was because I already had a native MySQL running on that port.
docker run --name db --detach --env="MYSQL_ROOT_PASSWORD=123" --publish=3306:3306 mysql:latest
I did a netstat --all --numeric --program --inet --timers | grep 3306 and noticed it gave me 1418/mysqld. Then I did a ps aux | grep mysql and noticed that was the same process number started by /usr/sbin/mysqld which was my local MySQL instance on my host, nothing to do with containers.
Double check nothing is using those ports, especially 8080, which is very common for stand alone web servers, like those that ship with IDEs.
If you are using that port, you can use the --publish option to specify the host port to be different but still use the same port on the container. i.e. --publish=8081:8080, hostport:containerport.

Resources