This repository provides a Podman container for setting up an iSCSI target service using Podman. It also includes instructions for creating a systemd service to ensure the container starts on host boot, along with the necessary volume for configuration.
- Podman installed on your system.
- Basic knowledge of systemd and iSCSI.
Follow the steps below to build the Podman container, create the necessary Podman volume, and set up the systemd service.
To build the Podman container, navigate to the root of the repository and run the following command:
podman build -t tgtd-image:v1 .This command will create a Podman image named tgtd-image:v1 based on the Dockerfile provided in this repository.
Next, you need to create a Podman volume that will hold the iSCSI target configuration files. Run the following command:
podman volume create tgt-confdThis will create a volume named tgt-confd, where you can store your configuration files.
Place your iSCSI configuration files into the tgt-confd volume. You can use the provided iscsi.conf as an example. To copy the configuration file into the volume, you can use:
podman run --rm -v tgt-confd:/etc/tgt/conf.d -v $(pwd)/etc-tgt-conf.d/:/mnt tgtd-image:v1 /bin/bash -c "[ ! -e /etc/tgt/conf.d/iscsi.conf ] && cp -v /mnt/iscsi.conf /etc/tgt/conf.d/iscsi.conf"Make sure to edit etc-tgt-conf.d/iscsi.conf with your configuration settings.
Now you can run the container using the tgtd-podman-run command to start the iSCSI target service. Use the following command:
./tgtd-podman-runThis script creates run the container and automatically builds a systemd file in the current directory.
To ensure that the container starts automatically on host startup, the tgtd-podman-run script creates a systemd service file name tgtd-podman.service.
The tgtd-podman.service can be soft-linkedin /etc/systemd/system/ as following:
ln -sv $(pwd)/tgtd-podman.service /etc/systemd/systemand at this point, you can enable and start the service:
systemctl enable --now tgtd-podman.serviceYou can check the status of the exported devices by running the command:
podman exec tgtd tgtadm --lld iscsi --mode target --op showYou have successfully built a Podman container for the iSCSI target service, created a Podman volume for configuration, and set up a systemd service to ensure the container runs on host startup.
For further customization, please refer to the provided configuration files and adjust the parameters as necessary. If you encounter any issues, feel free to open an issue in this repository.
This project is licensed under the MIT License. See the LICENSE file for details.