0

I want to execute a command that uses commands from multiple containers.

E.g., I want to execute a backup script that used psql and pg_dump commands.

docker exec db_backup pg_dump
failed to exec: exec: "pg_dump": executable file not found in $PATH

docker run has an option --link. Is there a similar option for exec?

To clear this up, there are 3 containers:

  • my_app
  • db
  • db_backup

I want to use pg commands located in db from my db_backup scripts.

2
  • how is my_app container related to the question? Commented Jan 17, 2015 at 22:46
  • my_app is a running application that is using db container. Commented Jan 17, 2015 at 23:22

2 Answers 2

1

There is not --link option for docker exec. If you want to backup using a special script:

  1. Create a new image db_backup starting from the postgresql one (the one that the db container uses), adding the backup script to some folder.
  2. Do docker run --volumes-from db db_backup your_backup_script.sh.
Sign up to request clarification or add additional context in comments.

Comments

0

1) go to the db shell by using sudo docker run -ti db /bin/bash

2) type which pg_dump or locate pg_dump if the first fails

3) use the full path in your command sudo docker exec db /full_path_to/pg_dump

run the 3) inside your db container

note: on my Fedora the pg_dump points to /usr/bin/pg_dump

3 Comments

There is no pg command in backup container. pg command is located in "db" container.
But I want to run pg_dump from db_backup container.
I.e. I want a backup script to be in a separate container.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.