-
Notifications
You must be signed in to change notification settings - Fork 0
Scripts Usage
This page documents all the possible usage of the [PHA Docker Files]
which is part of the [PHA Project]
.
The flags used in the scripts are all associated to the following tags:
Tag | Description |
---|---|
a |
CUSTOM_TAG is the tag used when building custom-images. |
b |
COM_FILE points to the docker-compose file. |
c |
CONT_NAME is used to name the container when it is run. |
d |
UID_VAR sets the UID of the user to the docker image. |
e |
ENV_FILE sets the environment file for docker compose. |
f |
DOCKERFILE_PATH sets the Dockerfile for building. |
g |
GID_VAR sets the UID of the user to the docker image. |
i |
DOC_IMG is the name of the docker image for all tasks. |
m |
CUSTOM_NAME is the name used when building custom-images. |
n |
DOC_IMG_NAME is used as an alternative to DOC_FILE to set the Dockerfile for building. |
o |
COM_COMMAND is used set the command for docker-compose. |
s |
SSI_PATH sets the path for the folder shared between the host and the container. |
t |
DOC_TAG is used to specify the tag for the docker image for all tags. |
u |
USERNAME sets the user to be passed to the docker image. |
The sample structure is connected to easily application and highly recommended:
cd /home/${USER}
mkdir schreibtisch
cd schreibtisch
git clone https://github.com/pradhanshrijal/pha_docker_files --recursive
cd pha_docker_files
This section builds images for the [PHA Project]
. The examples display all the flags available with the respective scripts, but the flags are all optional parameters.
This is a sample for the simple docker build command.
docker build -t phaenvs/pha-22:mini-sample -f envs/pha-22-mini/Dockerfile --no-cache .
This is a sample for the simple build script with the flag n
to specify the environments in the env
folder.
./build.sh -i phaenvs/pha-22 -n pha-22-mini -t sample
This scripts builds Dockerfiles, and the file path can be specified with the -f
flag.
./docker_scripts/build-file.sh -i phaenvs/pha-22 -f envs/pha-22-mini/Dockerfile -t sample
With this script, any PHA image can be selected to pass the user from the host.
./docker_scripts/build-user.sh -a custom-${USER} \
-d ${id -u} \
-f envs/custom-user/Dockerfile \
-g ${id -g} \
-i phaenvs/pha-22 \
-m phaenvs/pha-sample \
-t latest \
-u ${USER}
With this script, any docker image can be selected to pass the user from the host. This is the same file as above but with the default parameters set for general use-case.
./docker_scripts/build-general-user.sh -a custom-${USER} \
-d ${id -u} \
-f envs/custom-general-user/Dockerfile \
-g ${id -g} \
-i ubuntu \
-m ubuntu-22 \
-t 22.04 \
-u ${USER}
This section provides instructions to easily run the container from respective images. Please note that the scripts do not automatically stop or purge docker containers when finished.
This is a sample for run command for a docker container.
xhost +local:docker
docker run \
-d \
--name pha-22-mini \
-e DISPLAY=$DISPLAY \
--env=NVIDIA_VISIBLE_DEVICES=all \
--env=NVIDIA_DRIVER_CAPABILITIES=all \
--env=QT_X11_NO_MITSHM=1 \
--runtime=nvidia \
--privileged \
--shm-size=16gb \
--network host \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /home/${USER}/schreibtisch/pha_docker_files/docker_share:/home/pha/docker_share \
-v /media/${USER}:/media/pha \
-v /dev:/dev \
--gpus all \
-it phaenvs/pha-22:mini \
/bin/bash
This script packs the run command into simple instructions.
./run.sh -c pha-22-mini -i phaenvs/pha-22 \
-s /home/${USER}/schreibtisch/pha_docker_files/docker_share \
-t mini
This script packs the run command into simple CPU based instructions.
./docker_scripts/run-cpu.sh -c pha-22-mini -i phaenvs/pha-22 \
-s /home/${USER}/schreibtisch/pha_docker_files/docker_share \
-t mini
This script runs user specific containers.
./docker_scripts/run-user.sh -c pha-22-mini -i phaenvs/pha-22 \
-s /home/${USER}/schreibtisch/pha_docker_files/docker_share \
-t mini -u ${USER}
This script runs user specific containers with a CPU basis.
./docker_scripts/run-user-cpu.sh -c pha-22-mini -i phaenvs/pha-22 \
-s /home/${USER}/schreibtisch/pha_docker_files/docker_share \
-t mini -u ${USER}
In addition to the run commands, here are a few useful commands for the container.
./docker_scripts/exec-cont.sh -c pha-22-mini
./docker_scripts/stop-cont.sh -c pha-22-mini
./docker_scripts/rm-cont.sh -c pha-22-mini
Docker compose allows for a lot of flexibility. Variables and behaviours can be easily set by chaning the environment file or the compose file.
./docker_scripts/run-compose.sh -b docker_scripts/docker-compose.yaml \
-e docker_scripts/compose-file-mini.env
It is also possible to change the compose command with the same script. See [Compose Introduction]
for all the commands.
./docker_scripts/run-compose.sh -b docker_scripts/docker-compose.yaml \
-e docker_scripts/compose-file-mini.env -o down
With compose it is possible to directly build and run any PHA image with the host user passing in one go.
./docker_scripts/run-compose.sh -b docker_scripts/docker-compose-user.yaml \
-d $(id -u) -e docker_scripts/compose-file-user.env \
-g $(id -g)