Podman – Simple HTTP Uploader Container

Podman is very useful tool to rapidly deploy containers. In this post I just wanted to show you, how you can use Podman to deploy simple web uploader service, I used this for personal reasons in my local network so I can easily upload/download files on my local server through http without installing any http server.

First you need to pull the container, the container I used in this case is from docker.io:

podman pull docker.io/elementalnet/file-upload

Once it is downloaded you can run it as rootless container from non root user, I created a upload folder under user fred (/home/fred/Temp).

podman run –name “http_uploader” –privileged -d -t -p 8080:80/tcp -e SITE_NAME=”Local Upload Server” -e SITE_USERNAME=”saeed” -e SITE_PASSWORD=”saeed” -v /home/fred/Temp/:/var/www/upload/server/php/chroot/files/:Z docker.io/elementalnet/file-upload

 

Now the container is tagged as “http_uploader”; You need to provided ‘privileged’ parameter, this would give access from the guest container to host resource which is in this case is the folder that we want to upload our files to and make it persistence, so we won’t lose our files in case that the container is restarted or a system reboot.

Also if you are using SELinux protection you need to provide ‘:Z’ at the end of bind folders to apply appropriate container permissions on files. Otherwise SELinux would stop this.

Its good idea to create a service for the container, so it can be managed as a service, to do that you need to create a service file which can be done by podman and then added it as a service file to “/etc/systemd/system/<filename>.service”. Below is the sample service file for demonstration:

[fred@rocky-test system]$ podman generate systemd http_uploader 
# container-252e2fa68510e0cdfd1451253219f32192b26b02fb667b5aec248b8d870bebd9.service
# autogenerated by Podman 3.3.1
# Fri Nov 26 15:04:16 EST 2021

[Unit]
#this ensures the container runs with non root permissions 
User=fred
Group=fred
Description=Podman container-252e2fa68510e0cdfd1451253219f32192b26b02fb667b5aec248b8d870bebd9.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/tmp/podman-run-1001/containers

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStart=/usr/bin/podman start 252e2fa68510e0cdfd1451253219f32192b26b02fb667b5aec248b8d870bebd9
ExecStop=/usr/bin/podman stop -t 10 252e2fa68510e0cdfd1451253219f32192b26b02fb667b5aec248b8d870bebd9
ExecStopPost=/usr/bin/podman stop -t 10 252e2fa68510e0cdfd1451253219f32192b26b02fb667b5aec248b8d870bebd9
PIDFile=/tmp/podman-run-1001/containers/overlay-containers/252e2fa68510e0cdfd1451253219f32192b26b02fb667b5aec248b8d870bebd9/userdata/conmon.pid
Type=forking

[Install]
WantedBy=multi-user.target default.target

 

and here is running service:

podman uploader container

 

Hope this helps and good luck 🙂

Saeed



BTC: 1G1myr8rYv7SgyYtyWXLu3WLSPNaHCGGcd

Comments are closed.