Converting from docker to habitat for docker-compose


#1

I’ve converted my Dockerfiles to habitat plans, but when I run docker-compose up, the images can’t talk to each other.
I’m getting lines like this: curl: (7) Failed to connect to localhost port 80: Connection refused
And when an image tries to make a post request to another one, the log output says “connection refused”.
Is there some sort of port mapping I need to do in plan.sh?


#2

Sounds like you have an issue, with either a port the package is listening on, or some firewall type issue.

That’s where I’d start to look.


#3

I’m thoroughly confused, because I haven’t added any firewalls.

I haven’t changed the docker-compose.yml at all.

When running docker-compose up with images build with docker build, everything’s happy.

When I do the same thing with images build with hab studio build, there’s something blocking the networking.

The really confusing thing is the one image not being able to do curl on localhost:80. No matter what might be going on, it should be able to do that.


#4

Hmm, I’m sorry I was confused by your first post maybe. You are building your artifact, how are you running the artifact as a service? Like in your compose file you could be exporting the ports from one container to another and if you wanted to you could set up your package exports to reflect the same ports. And after you would either want to run the service under a hab supervisor or you could export it to docker (I haven’t tried this yet but I believe this what the docs state) and launching that docker instance should start your service and expose the ports specified.


#5

After I’ve built the project with hab studio build, I do hab pkg export docker path/to/hartfile.hart.
The compose file I have has 5 different docker images (4 of which are my habitat projects). The images in that cluster have ports exposed to each other. Something about building the packages with habitat as opposed to straight docker is blocking the networking.
The run hooks all do exec path/to/binary, so the actual services are all being managed by the hab supervisor.
I’m wondering if it’s some hostname resolution issue that habitat is preventing with the names in the docker compose file. Say webserver needs to contact database:3333. With the habitat-generated images, that resolution fails.


#6

I’m taking a look at this page and I think it’s an issue with how I currently have my compose file. I built their habitat image and exported it to docker (along with core/mysql). Everything worked as expected with their compose file.


#7

Okay. After a long day of sysadminning, I figured it out. I started up the cluster, tapped into one of the images, and ran netstat -lnp.
As it turns out, my service (a go webserver), is only listening on ipv6.
This didn’t happen with straight docker, though.
Any ideas on why that happened/how to fix the issue?