It only run the first command. The “\ l” is to list the databases but actually I’m going to use other commands instead. The “\ l” is just to simplify the situation, the example.
This command would be executed when I needed it and not just when the container go up.
The “\ l” was just an example. I must replace it later with other n commands.
I tried this too but it didn’t work:
This will help me to make several tasks more automated when using Docker.
Ah yes my bad, -c only allows you to execute a single command. You can get around this by using -f myfile.psql and put your commands in the file. Does it work out for you?
The file needs to be inside the container at the default location where docker exec puts you in. For the postgres:12.2 image, that’s simply root /. Find out with docker exec postgres-12.2 pwd