# Docker Container Execute on Host Client/Server App
[](https://bookstack.pknw1.co.uk/uploads/images/gallery/2025-01/scaled-1680-/HLPpknw1logo-white-png.png)
##### `/usr/local/bin/pipe-exec`
##### `/usr/local/bin/pipe-response`
****Client Server App for Host execution from within docker****
The app runs in the container and uses fifo pipes to pass commands to the server side of the app running on the docker host; the commands are executed and responses piped back to the container
****Server Side Component****
```
#!/bin/bash
# /usr/local/bin/pipe-exec
# server side of app
if ! [[ -p /var/run/exec ]]
then
[[ -d /var/run/exec ]] && rm -rf /var/run/exec
mkfifo /var/run/exec || echo "error" && exit 99
fi
if ! [[ -p /var/run/response ]]
then
[[ -d /var/run/response ]] && rm -rf /var/run/response
mkfifo /var/run/response || echo "error" && exit 99
fi
while true; do eval "$(cat /var/run/exec)" > /var/run/response; done
```
- [ ] pipe-exec runs on a docker host
- [ ] listens to fifo pipe /var/run/exec
- [ ] creates pipe if doesnmt exist
- [ ] executes the data from the pipe on the docker host
- [ ] sends output of the command to fifo pipe /var/run/response
- [ ] ideally run server component as a service
```
# systemd service file to run pipe-exec on startup
# /etc/systemd/system/pipe_exec.service
[Unit]
Description=Pipe Exec
[Service]
Type=simple
ExecStart=/usr/local/bin/pipe-exec
[Install]
WantedBy=multi-user.target
```
```
#!/bin/bash
# client side of app
# /usr/local/bin/pipe-response
echo "$1 $2 $3" > /var/run/exec
cat /var/run/response
```
****Client Application for inclusion and execution within docker container****
- [ ] `pipe-response` should be on the docker contaoner filesystem or mapped in as a volume
- [ ] `/var/run/exec` must be mapped as a volume
- [ ] `/var/run/response `must be mapped in as a volume
```
# example docker-compose.yml for mapping folders and script
# within the container pass commands as
# pipe-response curl ifconfig.me
# returns host IP
---
services:
your_container:
container_name: your_container
image: jamesread/your_container
user: root
volumes:
- ./config/your_container:/config
- /var/run/docker.sock:/var/run/docker.sock
- /var/run/exec:/var/run/exec
- /var/run/response:/var/run/response:ro
- ./config/pipe-response:/usr/bin/pipe-response:ro
restart: unless-stopped
networks:
- admin
environment:
- VIRTUAL_HOST=your_container.admin.pknw1.co.uk
- VIRTUAL_PORT=1337
networks:
admin:
external: true
name: admin
```
****further info****