0

I'm using a dedicated container for running generic project-related shell scripts in order to avoid having to test scripts on multiple environments(mac, win, ubuntu, debian...) and to minimize software requirements on the host OS. Even docker-compose commands are run from the console container. /var/run/docker.sock is bind mounted from host.

Everything else seems to be working fine, but for example if I run docker-compose up traefik inside the console container, traefik starts normally but it's unreachable both on the host and even on another container in the same network. If docker-compose up traefik is run from the host OS(Windows 10), traefik becomes reachable as expected. I suspect this has something to do with how Docker or docker-compose handle networking but I'm not completely sure. I did check that regardless of how I start the traefik container, the same ports appear instantly in NirSoft CurrPorts(sort of gui for netstat).

Is there any way (and how) to fix this?

EDIT I realised that this must be somehow an error on my part, since dockerized docker guis exist and they assumably don't have any problems bringing up containers that are accessible from the host and outside world.

Now I'm wondering if this might be a simple configuration error either in my docker(-compose) settings or somewhere else on my host machine, or do guis like Portainer go through some extra steps in order to expose the started containers to the host?

7
  • you can use linking. version: "3" services: web: build: . links: - "db:database" db: image: postgres Commented Dec 17, 2018 at 2:54
  • and how is unreacheable are able to run command inside container? Commented Dec 17, 2018 at 2:55
  • Not sure if I understood. I'm mounting the host docker socket to the container, similar to this: jpetazzo.github.io/2015/09/03/… The problem is that any container started from inside the console container are not accessible by browser even though they "should"(?) act just as if they were started directly from the host machine. Commented Dec 17, 2018 at 3:06
  • I tried to run like 1st: docker run --privileged -v /var/run/docker.sock:/var/run/docker.sock -ti jpetazzo/dind then 2nd: docker run -dit --rm -p 3000:3000 node:alpine 3rd: exec to nodejs container docker exec -it bc65c965339c ash 4th: npm i express -g 5th: npm i express-generator -g 6th: npm i && npm start i am able see response from node container Commented Dec 17, 2018 at 5:19
  • 1
    Thank you for your advice. Somehow I think there's more to this and there's something wrong somewhere else but I'll try it and get back to you as soon as I can. Commented Dec 17, 2018 at 18:59

1 Answer 1

1

For development purpose we all map the port of Traefik to 80, so I will assume the same in your case as well. Let's assume that you are running Traefik container in a port 80 which is mapped to the port 80 in the host. But according to your Traefik container the host machine is nothing but the container which is used for running the scripts. But the port 80 of the shell script container is not mapped to the Host machine of that particular container. I hope now you have been lost somewhere around the port mapping and containers.

Let me describe your situation in the image below.enter image description here

To make your setup working you should deploy your containers as shown above along with the port mapping. To simplify the answer,

docker run -t -d -p 80:80 shellScriptImage docker run -t -d -p 80:80 traefik (- inside the shell script container) 

By doing this you can access the traefik container from the outside.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I don't think that's the case though. The console container have Docker daemon running and it isn't a "host machine", but instead it controls the real host machine Docker daemon through the bind mounted socket. The problem is that due to some misconfiguration the containers spun up from within the console container can't be accessed via browser etc. even though the associated ports are mapped on the host machine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.