0

The scenario: I set a breakpoint in code, which is mounted (as a volume) into a container, created by docker-compose. The code is an odoo module, so it's part of the odoo container.

There is also a webapp container, which has a link to odoo in order to use the API.

The odoo container doesn't expose the API port because the host doesn't need it; the webapp container can, of course, see it.

services:
  odoo:
    volumes:
      - localpath:/mnt/extra-addons-bundles
  webapp:
    links:
      - odoo

Of course, the purpose of the breakpoint is to allow me to control the application - so I need a TTY attached. I can do this with docker-compose run --rm odoo. However, when I do this, it creates a new container, so the webapp never actually hits it. Plus, it doesn't tell me what the new container is called, so I have to manually figure it out to do that.

I can use docker exec to run another odoo in the odoo container but then I have to run it on a new port, and thus change the webapp config to use this new instance.

Is there a way of achieving what I want, i.e. to run the odoo container in interactive mode, such that the webapp container can see it, and without reconfiguring the webapp container?

2 Answers 2

0

The answer is to use tty: true in the docker-compose file, and docker attach to actually get that process attached to your terminal.

0

Try this and see if it works

services:
  odoo:
    volumes:
      - localpath:/mnt/extra-addons-bundles
    tty: true
    stdin_open: true
  webapp:
    links:
      - odoo

I have also added stdin_open in case you need it, if you don't just remove it

Edit-1

Also if you need to attach to the running container, then you need to use docker attach as docker-compose doesn't have that functionality

docker attach <containername>
4
  • As noted, I tried that - but I'm not confident that I made proper use of it. docker-compose up will not give me stdin, and docker-compose run is the source of the problem. Can you advise on which command I should use after doing this?
    – Altreus
    Sep 15, 2017 at 22:11
  • 1
    You won't get stdin with docker-compose. The way you run it would be like this. docker-compose up -d. Now if you want run on existing container use docker-compose exec odoo bash. if you want to attached to the main process in container then use docker attach <complete_container_name> Sep 16, 2017 at 4:58
  • I had no idea docker attach existed. When did that show up? With that and tty:true I got what I needed
    – Altreus
    Sep 16, 2017 at 18:45
  • @Altreus, updated the answer with that. It's been there for very long, its just that docker-compose doesn't expose that feature Sep 16, 2017 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.