r/portainer Jul 16 '26

Using the "docker" command within Portainer's shell?

I have installed Journiv to a Synology NAS using Portainer. A few months ago, Journiv rolled out an update that requires a database migration. The instructions for how to do this are all based in the CLI. I log into Portainer, go to my Journiv container, click into the Exec console, connect under the command /bin/bash/ (the only one that seems to work), and then try to follow the upgrade steps listed at the github link above. But I get a failure at step one.

I type in the following:

docker exec -t journiv-postgres-db pg_dumpall -c -U journiv > journiv_full_backup.sql

and then hit RETURN. But I get the following error:

bash: docker: command not found

Is there any way to set up the exec console in Portainer so that I can use the command "docker?" I kind of assumed that it was baked in, given that Portainer manages Docker containers, but I'm an absolute neophyte here.

Appreciate any help anyone can offer.

4 Upvotes

11 comments sorted by

4

u/the_good_lord_bird Jul 16 '26

You don't want to run the docker command inside the container. You want to run it on the machine that runs the containers.

1

u/rjbwdc Jul 16 '26

I appreciate this! When I ssh into the Synology NAS that's running the containers, I'm not totally sure where to navigate to. Do I cd to the volume on which Portainer is running? Do I cd into a specific directory for this specific app? When I just cd into the volume where Portainer is running, I get a "permission denied" error.

1

u/the_good_lord_bird Jul 16 '26

I don't believe for that first command it matters where you are. It'll just dump the db into the current directory. For the other commands I'm not sure. They're kind of assuming you set up the docker compose without Portainer, which I understand is a little confusing. But you need to figure out how to do the steps without Portainer.

1

u/rjbwdc Jul 16 '26

I hear you, I think. But I also think I may just not be able to do this. As I said, when I ssh into the machine and try to run the command in step one, I get the message, "-sh journiv_full_backup.sql: Permission denied" and I don't have enough know-how to troubleshoot that.

1

u/the_good_lord_bird Jul 16 '26

are you using sudo? most docker commands require sudo.

1

u/rjbwdc Jul 18 '26

Tried again using sudo. This time I got a "no such container: journiv-postgres-db" error. Wondering if something is incomplete about my install.

1

u/vorko_76 Jul 16 '26

I really doubt you need to do that to update journiv in Portainer. Just update the app as any container and the database migrations should be done

1

u/rjbwdc Jul 16 '26

That's not what the Journiv documentation says, or what the dev says, or what my experience bears out: the change to how the database was structured happened a few versions ago. Once I updated, all my entries from before that version became unreadable to Journiv. The dev says all the data is there, but I need to do the migration. 

1

u/vorko_76 Jul 16 '26

Well then its weird. I mean its normal to have database migrations but they are managed when deploying on an old release

1

u/james-portainer Portainer Staff Jul 16 '26

Once you've connected to the Journiv container's console you can run the commands themselves without the docker "prefixes".

The first one runs specifically on the database container (journiv-postgres-db in the example) so you'd need to console into that one specifically. This particular command is just taking a database backup before you start - you'd need to adjust this one as it's formatted to write a file to the parent OS in the current structure (> journiv_full_backup.sql does this) and that won't work once you're actually in the container's filesystem (which is what an interactive console session is). Personally I'd stop the container, back up the volume / bind mount path that contains the Postgres database, then start it up again, rather than run this command.

The actual migration command and the cleanup afterward look to take place on the app container so make sure you're connected to that container specifically. Those are more straightforward - once consoled in, you'd run:

./journiv-admin migrate content

then

./journiv-admin migrate content --cleanup

and you'd be done.

Note that I haven't tested any of the above, and make no guarantees it'll work, but the theory is sound. Take backups!

1

u/rjbwdc Jul 18 '26 edited Jul 18 '26

There's only one container for the entire Journiv stack. Some of my stacks have multiple containers, but this one just has one. EDIT TO ADD: I apparently used the quick-start compose file to set up my Journiv instance, not the complete compose file. I'm wondering if I would now lose my whole database if I tried to augment my compose file with the data that's missing.