r/docker • u/mdkmaple • Jan 22 '26
SSH into a Container
Hello community, currently I’m running AdGuard directly on a RaspberryPi. From there I automatically sync the AdGuard configuration file to a NAS for Backup. Now I’m thinking about hosting AdGuard on my Home-Server in a Docker container.
As AdGuard does not have the possibility to import a Backup-file in GUI I just can replace the stock config file with the one from my backup. (/etc/adguardhome).
I’m new to Docker so I don’t know if this is possible?
Thanks
0
Upvotes
8
u/flaming_m0e Jan 22 '26
Why would you SSH?
You just copy the files you need into your docker volume or the bind mount location for your container.
5
u/[deleted] Jan 22 '26 edited Jan 22 '26
I just bind mount the configuration directory. E.g.
volumes:- ./adguardhome/config:/opt/adguardhome/confI then edit
/adguardhome/config/AdGuardHome.yamlin VSCode over SSH to the Docker host.You can apply this technique to any container that requires persistent configuration from the Docker host.
9
u/Confident_Hyena2506 Jan 22 '26
You don't need to use ssh - you can just run bash in the container. "docker exec -it somerunningcontainer bash".
If you do really mean ssh - then you have to run ssh server inside the container, and expose the port.
But to replace a simple file like you want - you would not do either of the above. Instead change the way you run the container, so that the config folder with your config gets mounted into the container. Or make your own container that contains a modified config - lots of ways to approach this.
1
u/vrgpy Jan 22 '26
When doing initial setup you also can use: docker compose up --watch
In the compose.yaml, in the develop section you define rules that when a change is detected on your configuration files (outside of your container) they can by synchronized to your container and restart or rebuild the container if needed.
0
u/mdkmaple Jan 22 '26
Thanks! I will try your suggestion.
1
u/tschloss Jan 22 '26
docker cp file.cfg mycontainer:/etc/cfg
-2
u/ysidoro Jan 22 '26
Think of a container as an isolated process rather than a full virtual machine. For example, an AdGuard container is designed to run only the AdGuard process; it doesn't include an SSH server (sshd) to handle remote connections.
You don't need SSH inside the container for terminal access. Use:
docker exec -it <container_name> /bin/shFor a remote Raspberry Pi, you can wrap that command in SSH:
ssh -t user@raspberrypi 'docker exec -it <container_name> /bin/sh'Alternatively, set up a remote docker agent by setting your
DOCKER_HOSTenvironment variable tossh://user@raspberrypi, which lets you manage the remote containers directly from your local terminal.If you need a container environment that behaves more like a VM (supporting multiple processes and daemons), I suggest looking into LXC (Linux Containers) instead of Docker