-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-compose up -d doesn't expose ports when defined with build directive #4799
Comments
Are you using the |
@shin- |
this probably is a better sample. using the same image and doing the same thing but ports setting under build for port 9999 is not published.
|
tried with
|
Port mapping is incompatible with
https://docs.docker.com/engine/userguide/networking/#default-networks |
AH!! great catch. totally missed it even when I created this test files. |
so what was the solution exactly? |
I'm having the same issue, and I'm not using the
|
@b4dnewz you cannot use port-mapping when using host network_mode because it's designed to expose all ports as written in Dockerfile. (see details in the link @shin- mentioned above) = use other network mode. @gaillota not sure about your issue but I suspect that it was run by a regular user? (port 80 needs system admins' privilege to open) |
@akadoya Thank you for you quick answer and sorry if my issue was not clear enough. |
@gaillota oh I see, port should be mapped as HOST:CONTAINER so you need to swap position of 3000/80 port numbers in your compose file. |
never mind... your file seems right.. |
I'm having a problem with the ports on the .yml file it seems to be not working, or maybe I'm doing something wrong. Dockerfile
docker-compose.yml
And when I inspect the container the Network output is the following:
The only work around for this is running: With that I got:
Any idea? |
|
|
oh, you didn't specify, but I'm assuming you're using |
What's the error?
2018-02-27 6:36 GMT-06:00 Jáchym Toušek <[email protected]>:
… I'm experiencing the same problem even when using docker-compose up. Any
ideas how to solve it?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4799 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIaBKnXIPaz39XZS3ba5YZ8QRn9LAm7Zks5tY_bigaJpZM4NSip0>
.
--
Alberto Manuel Rojas Mendez
|
…work_mode: host` Took a while to figure this one out. Source: docker/compose#4799 (comment)
…work_mode: host` Took a while to figure this one out. Source: docker/compose#4799 (comment)
* `network_mode` and `ports` are incompatible. * docker/docs#6448 * docker/compose#4799
* `network_mode` and `ports` are incompatible. * docker/docs#6448 * docker/compose#4799
NOTE : The host networking driver only works on Linux hosts, and is not supported on Docker for Mac, Docker for Windows, or Docker EE for Windows Server. |
Hi! I am having same issues: I want to send RPC commands using curl from the docker command line to the containers but it returns a timeout error. Here is my docker-compose.yml:
docker-compose version:
I execute |
try running |
@robert197 Thanks for that! I was really confused why my docker container wasn't working. Do you know how to get docker to use |
@KevinKelbie I think you can achieve that by using Docker Desktop on Mac instead of Docker Machine: https://docs.docker.com/docker-for-mac/docker-toolbox/ |
I'm going to post this here in case anyone else ran into the same issue I did. I discovered that if you use a dockerfile that functions like a builder script (containing the AS after from) like this example:
Docker Compose will not expose the ports properly, or name the container after the service either. I ran into this issue because I just started learning docker compose and I copied some code from another builder script I made... not catching the fact I forgot to remove the stage. |
I am facing the same problem my
The command I am using is |
I've found that
This service is unavailable from the host machine. But add network used by all containers, started with
Then |
@kmursk That was it for me, thanks 🎉 Shouldn't docker at least print a |
the port 3001 is not exposed, why ? |
#4799 (comment)
Start and look at container's status. It should be something like that:
So i assume there can be 2 kind of troubles:
|
Thanks for the quick reply @kmursk, i have an express-app that listen on port 3001, and the console show "running on port 3001" in the container
And even with that changes postgres container doesn't run. But if i run it alone it works. This stuff are very confusing !
the command that i use |
For me the problem was that my service, that I was running in the docker container, was hosted on 127.0.0.1 instead of 0.0.0.0 which makes the service inaccessible from the host system even if the port is published. |
This flag is invalid on compose up. You can only use it on compose run. |
@gooney47 was right use
|
@gooney47 if I could give you more emojis I would, thank you!!!! |
The problem in my case was that I had specified a port on the host which was already in use by another process. I had the following port configuration:
There was a process listening on 20080 (PhpStorm's zend debugger broadcast settings listener) on the host. As far as I remember docker-compose used to complain when starting services having published ports which are already in use. Output of
What's even weirder is that port 20022 does get published but the other free ports 20001 and 20800 do not. If I close PhpStorm or comment out the 20080 port all ports are published successfully. |
so what is the solution here? was it displaying 127.0.0.1 when you type docker ps? for me it display 0.0.0.0:1433 |
In my case (Ubuntu 20.04 LTS), I just stopped apache2 service that was using "*:80" ports, and in my container I needed "80:8080" port. To see the ports being used:
After running |
For me it showed |
For the love of code everyone read the answer by @gooney47. Hours wasted... |
Define in your docker-compose the correct CMD for uvicorn: FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY . /code/
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] and in your docker-compose fit it to the correct port: version: "3.9"
services:
backend:
build: .
ports:
- "8000:8000"
|
docker-compose up -d
is supposed to expose the ports and supposedly be able to publish the ports according to the yml, however, it is not working for the services build frombuild:
configuration.docker-compose.yml
Dockerfile for nginx
These files above end up like this:
so..ports configuration seems working for containers that is built from image pull, but not for containers built from a local dockerfile.
The text was updated successfully, but these errors were encountered: