-
Notifications
You must be signed in to change notification settings - Fork 279
Many ports exposed, constraints it from scaling the containers due to address conflict #117
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
Comments
Expose does not control the ports that are published to the host. They only define the "contract" of ports that this container might use (which might not use all but it depends on configuration). The mapping to host ports is controlled at run time. Just map the ports to different ports for each container you want to run or let Docker choose random unused ports for you. $ # manually picking ports:
$ docker run -d -p 7001:7001 -p 7199:7199 -p 9042:9042 --name cass1 cassandra
$ docker run -d -p 7002:7001 -p 7200:7199 -p 9043:9042 --name cass2 cassandra
$ # or let docker pick ports for all items defined by EXPOSE
$ docker run -d -P --name cass1 cassandra
$ docker run -d -P --name cass2 cassandra
$ docker run -d -P --name cass3 cassandra
...
$ # you can even map any port of the container, but that doesn't mean it will actually
$ # respond there and doesn't even need an EXPOSE defined in the Dockerfile
$ docker run -d -p 8080:80 --name cass1 cassandra |
I am using docker-compose to run the container, in which I have not mapped the ports at all Still when I scale the instance to more than one, I get this error, hence I am of opinion the ports are getting mapped automatically since the image has suggested that it is exposing these ports Am I missing something? |
Can you share your |
Hi below find them === START OF DOCKERFILE =====
=== END OF DOCKERFILE ===== === START of docker-compose.yml ====
=== END of docker-compose.yml ==== |
The root of the problem is Not related to your port conflicts, but a second problem is that cassandra is not running in the container; the only process started in the container is version: '2'
services:
nodejs:
image: customnodejs:0.1.0
build: ./
restart: always
environment:
- 'CASSANDRA_URL=cassandra://cassandradb:9042/'
volumes:
- ../data:/data
cassandradb:
image: cassandra:3.11.0 |
Yes, network mode is a issue it can be solved by switching to Bridge, but I think docker should have got something to override the port expose in the extending image However I solved it using a shell script, which I wrote, which starts cassandra and then runs the node code, I also switched to Network mode I am closing this issue as of no |
If we use cassandra as parent docker image we cannot scale such containers more than one, because it gets into error saying ADDRESS IN USE, as base docker image exposes so many ports
Can we have a mechanism to not expose them, instead expose them at run time or in the extended Dockerfile?
OR can we comment this line in the Dockerfile
EXPOSE 7000 7001 7199 9042 9160
The text was updated successfully, but these errors were encountered: