Debugging connected docker containers when using docker

Suppose I have the following file docker-compose.ymlthat runs two different python applications in parallel (e.g. via a jar):

app1:
  command: python app.py
  build: app1/

app2:
  command: python app.py
  build: app2/
  links:
    - app1

app2connected with app1, since I want to get certain data from it in it app1. Now my problem is a certain scenario when I want to debug this link. I can easily debug app1both app2as standalone containers (through docker-compose run --service-ports ... python app.pyand placing pdbsomewhere in the code). My problem is when I want to debug app1if the request comes from app2. If I start app1with docker-compose run, then app2cannot resolve the link. This problem becomes even more problematic when more applications / services "talk" to each other depending on their links.

Is there a good way to handle this? How do you feel about the debugging problem with related containers in general (not necessarily python specificc)? Thanks for the input.

+4
1

, net: 'host' , :

Docker . , Docker , !

.

app1:
  command: python app.py
  build: app1/
  net: 'host'

app2:
  command: python app.py
  build: app2/
  net: 'host'

, 1 app2 :

docker-compose up -d app1
docker-compose run app2

app1 app2, (pdb) app2

+4

Source: https://habr.com/ru/post/1589267/


All Articles