Service abstracting with Docker Compose

I am having problems with what should have been defined in some Docker Compose services from my "main" service ( web). I have the following docker-compose.ymlfile:

version: '2'

services:
 db:
   image: postgres
   volumes:
    - postgres-db-volume:/data/postgres
 pdftk:
   image: mnuessler/pdftk
   volumes:
    - /tmp/manager:/work
 ffmpeg:
   image: jrottenberg/ffmpeg
   volumes:
    - /tmp/manager:/files
 web:
   build: .
   command: python manage.py runserver 0.0.0.0:8000
   volumes:
     - .:/code
     - /tmp/manager:/files
   ports:
     - "8000:8000"
   depends_on:
     - db
     - pdftk
     - ffmpeg

volumes:
   postgres-db-volume:

I can use dbfrom webfine, but unfortunately not pdftkor ffmpeg(these are just command line utilities that are undefined when I run the shell web):

manager$ docker-compose run web bash
Starting manager_ffmpeg_1
Starting manager_pdftk_1
root@16e4b755172d:/code# pdftk
bash: pdftk: command not found
root@16e4b755172d:/code# ffmpeg
bash: ffmpeg: command not found

How can I get pdftkand ffmpegto determine in the service web? Is depends_onnot a relevant directive? Should I distribute a webDockerfile to invoke a script entry point that sets the content found in two other services (although this seems counterproductive)?

web pdftk ffmpeg, .

?

!

+4
3

"depend_on". .

: - ..

, , ssh-, :

ssh pdftk <your command>

-. Docker , .

0

: OP. .


, @opHASnoNAME..., pdftk ffmpeg , :

ffmpeg:
  volumes:
    - /usr/local/bin

-:

web:
  volumes_from:
    - ffmpeg

, :

  • /usr/local/bin, ffmpeg, , .
  • web, /usr/local/bin $PATH.
  • , - Linux, .. - .
  • , volumes volumes_from,

, docker docker-compose.

0

"" SSH, , , . " " depend_on.

Depends_on , , " ruff". , , , db , - depends_on right , , , , , , , .

, -. :

services:
web:   
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock

, -, , :

docker exec pdftk <thecommand>

.

Of course, you can use http / api-based implementations, in this case you do not need to set any ports or mount a socket, moreover, you can access services using their service name

ping pdftk or ping ffmpeg

0
source

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


All Articles