Skip to content
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

How to use blockade API inside container #75

Open
HerculanoGripp opened this issue Nov 14, 2018 · 1 comment
Open

How to use blockade API inside container #75

HerculanoGripp opened this issue Nov 14, 2018 · 1 comment

Comments

@HerculanoGripp
Copy link

HerculanoGripp commented Nov 14, 2018

Hi guys, first of all thanks for the great tool.

I'm trying to use Blockade in my stack of tests and have some doubts. I have two containers one is server and other one is the client. I'm running my tests in client and in some cases need to change network parameters of server or client container. In documentation tells about Blockade API but i don't know how to use the API inside client container.

See below my setup configuration of blockade.yaml file

  containers:
  server:
    image: ubuntu:trusty
    command: sh -c "/bin/sleep 300000"
    volumes: ".": "/home/server/"
    expose: [80]
    ports: [5000]

  client:
    image: ubuntu:trusty
    command: sh -c "echo $SERVER_PORT_5000_TCP_ADDR ' google.com.br' >> /etc/hosts; ping $SERVER_PORT_5000_TCP_ADDR"
    volumes:
      "/home/user/client_app": "/home/client_app"
    links: ["server"]

  network:
  flaky: 80%
  slow: 75ms 100ms distribution normal
@labisso
Copy link
Member

labisso commented Nov 17, 2018

The API is bound to the host, not one of the containers. So if you want to access it from a container, you'll need to know an IP address or hostname for the host. This is more complicated than it should be and I think it can even vary depending on whether you are using Docker for Mac/Windows versus from Linux directly. Here is is a blog post and sample code you could use to do this:
https://dev.to/bufferings/access-host-from-a-docker-container-4099
https://github.com/bufferings/docker-access-host

Once you figure out the hostname, you should be able to directly connect to the Blockade API port on that hostname (default: 5000). I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants