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

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

Related

Apache Pulsar installation in Windows Docker

Could you please help me how to install a local standalone pulsar cluster using windows docker.i have followed the below options.but i couldn't able to access the pulsar UI
8080 port is already allocated for some other process.so here i'm using 8081 port.
Option 1:
docker run -it -p 6650:6650 -p 8081:8081 --mount source=pulsardata,target=/pulsar/data --mount source=pulsarconf,target=/pulsar/conf apachepulsar/pulsar:2.5.2 bin/pulsar standalone
Option 2:
docker run -it -p 6650:6650 -p 8081:8081 -v "$PWD/data:/pulsar/data".ToLower() apachepulsar/pulsar:2.5.2 bin/pulsar standalone
Using the above two options, i couldn't able to see the INFO - [main:WebService] - Web Service started at http://127.0.0.1:8081.Also i'm not able to access the following url in the system.
pulsar://localhost:6650
http://localhost:8081
Thanks
The problem is the mapping between the ports. It is clear that you cannot use 8080 on your side, but the port 8080 should be still used within the container, because this port is used by the service. The correct command is:
docker run -it -p 6650:6650 -p 8081:8080 apachepulsar/pulsar:2.5.2 bin/pulsar standalone
It makes sense to try it out without the volumes first and add them later.

Docker published ports are not accessible except for 3000

I have a feeling the question I'm about to ask is silly but I can't find the solution to my issue and I've been on this problem for a while now.
I am trying to run a docker container for a node application with a command that looks similar to the following:
$ docker run --rm -d -p 3000:3000 <username>/<project>
The above command is working fine. However, when I attempt to map my ports to something different like so:
$ docker run --rm -d -p 3000:8080 <username>/<project>
...The program doesn't work anymore
EDIT: To answer the questions in the comments. I've also tried ports 5000 and 7000 and I'm sure their not in use.
I think you're attempting to change the wrong port in the mapping:
docker run --publish=${HOST_PORT}:${CONTAINER_PORT} <username>/<project>
Maps the host's ${HOST_PORT} to the container's ${CONTAINER_PORT}.
Unless you change the container image's configuration, you're more likely to be choosing a host port.
What happens if you:
docker run --rm -d -p 8080:3000 <username>/<project>
And the try (from the host), e.g. curl localhost:8080?

Error while using docker run

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.

docker -P not exposing ports of application started as argument

I'd like to start a container with an argument to start a server inside the container. The problem is the -P switch is not exposing the ports of this server to my host.
docker run -it -e "JAVA_HOME=/opt/jdk1.8.0_45" -e "CARBON_HOME=/opt/IOT/wso2iots-1.0.0-SNAPSHOT" -P ubuntupreped:2.0 /bin/sh /opt/IOT/wso2iots-1.0.0-SNAPSHOT/bin/wso2server.sh
When I build a image exposing the env variables and a script to start the server, the -P switch works as expected.
Any idea whats happening here?

Access service running in docker container from inside another docker container

At the moment I'm running a node.js application inside a docker container which needs to connect to camunda, which runs in another container.
I start the containers with the following command
docker run -d --restart=always --name camunda -p 8000:8080 camunda/camunda-bpm-platform:tomcat-7.4.0
docker run -d --name app -p 3000:3000 app
Both applications are now running and I can access camunda by navigating to my host's IP on port 8000, and running wget http://localhost:8000 -q -O - also returns the camunda page. When I login to my app container with docker exec -it app sh and type wget http://localhost:8000 -q -O -, I cannot access camunda. Instead I get the following error:
wget: can't connect to remote host (127.0.0.1): Connection refused
When I link my app container to the camunda container with --link camunda:camunda, and type wget http://camunda:8000 -q -O - in my app container, I get the following error:
wget: can't connect to remote host (172.17.0.4): Connection refused`
I've seen this option, so I started my app container with --add-host camunda:my_hosts_ip and tried wget again, resulting in:
wget: can't connect to remote host (149.210.227.191): Operation timed out
When running wget http://149.210.227.191:5001 -q -O - on my host machine however, I get a correct response immediately.
Ideally I would like to just start my app container without the need to supply the external IP in any way, and let the app container just use the camunda service via the localhost or by linking the camunda container tot my app container. What would be the easiest way to achieve this?
Why does it not work?
Containers and host do not share their local IP stack. Thus, when you are within a container and try anything localhost:port the anything command will try to connect to the container-specific local IP stack, not the other container nor the host.
How to make it work?
Hard way: you either need to know the IP address of the other container and connect to this IP address..
Easier and cleaner way: .. either link your containers.
--link=[]
Add link to another container in the form of <name or id>:alias or just <name or id> in which case the alias will match the name
So you'll need to perform, assuming the camunda container is named camunda:
docker run -d --name app -p 3000:3000 --link camunda app
Then, once you docker-exec-ed into the container app you will be able to execute wget http://camunda:8080 -q -O - without error.
Note that while the linked containers graph cannot loop, e.g., camunda cannot be linked to app as you need to start a container to be able to link it, you actually do whatever you want/need playing with IP addresses.
Note also that you can specify the IP address of a container using the --ip option (though it can only be used in conjunction with --net for user-defined networks).
Original answer below. Note that link has been deprecated and the recommended replacement is network. That is explained in the answer to this question: docker-compose: difference between network and link
--
Use the --link camunda:camunda option for your app container. Then you can access camunda via http://camunda:8080/.... The link option adds a entry to the /etc/hosts file of the app container with the IP address of the camunda container. This also means you have to restart your app container if you restart the camunda container.

Resources