I'm using AzerothCore with Docker.
I've noticed that after running docker-compose down and docker-compose up my worldserver and the database now uses different ports than the defaults. How to prevent this?
Note: the authserver port remained the same.
I use Windows 10 20H2 (Build 19042.844)
Normally docker creates automatically a tunnel on a random free port for any service that tries to bound on its own network.
However, unless you changed the WORLD_EXTERNAL_PORT or the port is already busy for some reason, the original port (together with the random one) should be open as well.
you can run the docker-compose ps or the docker ps to check which are network ports open.
Also, this behaviour changes based on your OS. Can you specify it in your first post, please?
thanks for the prompt reply, I haven't changed anything about WORLD_EXTERNAL_PORT, as for 'docker-compose ps' again my overwhelming inexperience comes out hehe, dont know where to enter the command, the 'docker ps' gives this result:
Related
I recently installed Docker on my Raspberry Pi 4 and connected it to a portrainer instance on my other server. On my Raspberry Pi I created two docker containers, but somehow docker automatically creates random ubuntu containers with names like:
I don't have an idea why it is doing this: /
But when I delete those Containers, a few hours later there are some other containers again.
I hope anyone can help me with that kind of problem.
Ok i think i solved this question...
I run this webinterface (Portrainer) on my public hosted server. And i only shared my ip with my port for Portrainer as "Endpoint" and now i have disabled the port on my raspberry for all other IPs then my Raspberry PI. And now i solved this problem. No container is created anymore. I came up to this solution, because i saw the infos, this container was created and it "wgets" some ".sh"-file from some ip with executing some shell commands. And i thought, "this is not from mine, this is someone want to mine some bitcoins on my raspberry". (because this script downloaded some mining scripts.....
:PS: My english is very bad. But i hope it helped someone other.
Those random names are created automatically when a container is started without a name attribute. If you did not start an unnamed container yourself (by issuing docker run without the --name option), those are most likely being created by a docker build.
You can delete those stopped containers manually one at a time or use commands like docker system prune (see docker help system prune for documentation) to cleanup your daemon from unused objects (including those stopped containers).
When I run docker command
docker run -d -P nginx
docker will run and auto allocate port for nginx's port 80. If I stop the image and start it again, a new port will be allocated to nginx (normally next one available).
As I found out, the range for port allocation is based on ephemeral port range , in docker case default is 32768 - 61000. (https://docs.docker.com/v17.09/engine/userguide/networking/default_network/binding/)
How and when does docker recycle ports? Will it go back to 32768 or nearest available?
It took a lot of time for me to find out but docker doesn't do much.
I dived into docker-ce source files and saw that it uses a function RequestPortInRange which simply gives the next available port.
Now, when you run docker run -d -P nginx command, docker gives you the first available port in the "ephemeral range" i.e. 32768 - 61000 ( as you pointed out).
Once you destroy /stop the container, it should resume to 32768, However, it goes to the next available port i.e. 32769 ( on my computer at least).
So, I thought may be it takes sometime for linux or any OS to take back the port after the container is destroyed but netstat -lntu confirms that the port isn't in use any more.
So, my theory is (which may be entirely wrong, in which case I will be glad to be corrected ), that it creates one instance of PortAllocator thing and thus it has a state. so, the next time docker run -P ... is called, it goes for the next available port. This is also corroborated by the fact that even when you create other containers, the docker engine is providing you the next available port not the previous yet available ones.
I hope i answered your question and i don't know much of golang so, forgive any mistake in terminology.
In our solution we want to connect our Edge module to the servicebus of a host on a different network.
The dns server is not allowed (per design) to have the dns mapping to that host, hence I need to do the dns mapping in the hosts file of the Windows container that the Edge module is running in.
I have done some tests with the docker run and docker build commands, setting the --add-host parameter, but this doesn't seem to be supported in Windows containers. Looking at the file after the container has been started with that flag at least suggests that it is not.
Moreover I'm not sure I can use this since the Edge runtime is in control of the running of containers (please correct me if I'm wrong here).
In my desperation I tried to modify the hosts file through code, but got stopped due to administrative previledges not beeing met.
Anyways this feels like a hack and is not what one should have to do.
Is there an easier way to add a dns host mapping?
Assuming that you are using a windows base image - you could modify the hosts file there.
I did it with cmd, like this
docker exec --user "NT AUTHORITY\SYSTEM" -it <container> cmd
and when I got that shell I've run:
echo x.y.z.w hostname >> c:\windows\system32\drivers\etc\hosts
at first i've tried with powershell but all I got was some weird blank spaces between my text
I am using VS2017 docker support. VS created DockerFile for me and when I build docker-compose file, it creates the container and runs the app on 172.x.x.x IP address. But I want to run my application on localhost.
I did many things but nothing worked. Followed the docker docs as a starter and building microsoft sample app . The second link is working perfectly but I get HTTP Error 404 when tried the first link approach.
Any help is appreciated.
Most likely a different application already runs at port 80. You'll have to forward your web site to a different port, eg:
docker run -d -p 5000:80 --name myapp myasp
And point your browser to http://localhost:5000.
When you start a container you specify which inner ports will be exposed as ports on the host through the -p option. -p 80:80 exposes the inner port 80 used by web sites to the host's port 80.
Docker won't complain though if another application already listens at port 80, like IIS, another web application or any tool with a web interface that runs on 80 by default.
The solution is to:
Make sure nothing else runs on port 80 or
Forward to a different port.
Forwarding to a different port is a lot easier.
To ensure that you can connect to a port, use the telnet command, eg :
telnet localhost 5000
If you get a blank window immediatelly, it means a server is up and running on this port. If you get a message and timeout after a while, it means nobody is running. You anc use this both to check for free ports and ensure you can connect to your container web app.
PS I run into this just a week ago, as I was trying to set up a SQL Server container for tests. I run 1 default and 2 named instances already, and docker didn't complain at all when I tried to create the container. Took me a while to realize what was wrong.
In order to access the example posted on Docker Docs, that you pointed out as not working, follow the below steps,
1 - List all the running docker containers
docker ps -a
After you run this command you should be able to view all your docker containers that are currently running and you should see a container with the name webserver listed there, if you have followed the docker docs example correctly.
2 - Get the IP address where your webserver container is running. To do that run the following command.
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" webserver
You should now get the IP address which the webserver container is running, hope you are familiar with this step as it was even available within the building Microsoft sample app example that you attached with the question.
Access the IP address you get once running the above command and you should see the desired output.
Answering to your first question (accessing docker container with localhost in docker for windows), in Windows host you cannot access the container with localhost due to a limitation in the default NAT network stack. A more detailed explanation for this issue can be obtained by visiting this link. Seems like the docker documentation is not yet updated but this issue only exists in Windows hosts.
There is an issue reported for this as well - Follow this link to see that.
Hope this helps you out.
EDIT
The solution for this issue seems to be coming in a future Windows release. Yet that release comes out this limitation is available in Windows host. Follow this link -> https://github.com/MicrosoftDocs/Virtualization-Documentation/issues/181
For those who encountering this issue in 2022, changing localhost to 127.0.0.1 solved an issue for me.
There is other problem too
You must have correct order with parameters
This is WRONG
docker run container:latest -p 5001:80
This sequence start container but parameter -p is ignore, therefore container have no ports mapping
This is good
docker run -p 5001:80 container:latest
Seems real simple, but I'm not sure what to do now. I have docker on OSX and I'm want to try out espeakbox. So I ran
the command mentioned here.
to "run a container"
It's evidently running:
bash-3.2$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
705a605786c7 parente/espeakbox "/server" 34 seconds ago Up 33 seconds 0.0.0.0:8080->8080/tcp espeakbox
So, what do I do now, to use see it, hear it, etc.
Thanks.
There's full instructions on the GitHub page, so I'm loath to answer this question. However, I'm assuming the confusion is that you're not sure where the container is running. If you're using boot2docker, Just do:
$ curl http://$(boot2docker ip):8080/speech?text=hello
I assume it sends back an mp3 file.
Basically, the docker run command told Docker to forward port 8080 on the container to port 8080 on the host. When using boot2docker, the host is a Virtualbox VM, so we need to use the IP of the VM to connect to the service.