-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DOCKER_REPOSITORY_NAME to reusable workflow
Use variables for Docker image name
- Loading branch information
Showing
11 changed files
with
113 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,21 +9,29 @@ You can build the image like this: | |
``` | ||
#!/usr/bin/env bash | ||
DOCKER_REPOSITORY_NAME="rubensa" | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
DOCKER_IMAGE_TAG="latest" | ||
docker buildx build --platform=linux/amd64,linux/arm64 --no-cache \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
--label "maintainer=Ruben Suarez <[email protected]>" \ | ||
. | ||
docker buildx build --load \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
. | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
. | ||
``` | ||
|
||
To make an Nvidia GPU available in the docker container, the following steps have to be taken: | ||
|
||
``` | ||
#!/usr/bin/env bash | ||
DOCKER_REPOSITORY_NAME="rubensa" | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
DOCKER_IMAGE_TAG="latest" | ||
# NVidia propietary drivers are needed on host for this to work | ||
NVIDIA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader) | ||
|
@@ -34,11 +42,17 @@ prepare_docker_nvidia_drivers_version() { | |
prepare_docker_nvidia_drivers_version | ||
docker build --no-cache \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
# see: https://github.com/docker/buildx/issues/495#issuecomment-761562905 | ||
#docker buildx build --platform=linux/amd64,linux/arm64 --no-cache --progress=plain --pull \ | ||
docker buildx build --platform=linux/amd64,linux/arm64 --no-cache \ | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
--label "maintainer=Ruben Suarez <[email protected]>" \ | ||
${BUILD_ARGS} \ | ||
. | ||
docker buildx build --load \ | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
. | ||
``` | ||
|
||
## Running | ||
|
@@ -48,6 +62,10 @@ You can run the container like this (change --rm with -d if you don't want the c | |
``` | ||
#!/usr/bin/env bash | ||
DOCKER_REPOSITORY_NAME="rubensa" | ||
DOCKER_IMAGE_NAME="ubuntu-tini-dev" | ||
DOCKER_IMAGE_TAG="latest" | ||
# Get current user UID | ||
USER_ID=$(id -u) | ||
# Get current user main GUID | ||
|
@@ -128,7 +146,7 @@ prepare_docker_printer_host_sharing() { | |
} | ||
prepare_docker_ipc_host_sharing() { | ||
# Allow shared memory to avoid RAM access failures and rendering glitches due to X extesnion MIT-SHM | ||
# Allow shared memory to avoid RAM access failures and rendering glitches due to X extension MIT-SHM | ||
EXTRA+=" --ipc=host" | ||
} | ||
|
@@ -171,15 +189,15 @@ prepare_docker_hostname_host_sharing | |
prepare_docker_nvidia_drivers_install | ||
docker run --rm -it \ | ||
--name "ubuntu-tini-x11" \ | ||
--name "${DOCKER_IMAGE_NAME}" \ | ||
${SECURITY} \ | ||
${ENV_VARS} \ | ||
${DEVICES} \ | ||
${MOUNTS} \ | ||
${EXTRA} \ | ||
${RUNNER} \ | ||
${RUNNER_GROUPS} \ | ||
rubensa/ubuntu-tini-x11 | ||
"${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" "$@" | ||
``` | ||
|
||
*NOTE*: Mounting /var/run/docker.sock allows host docker usage inside the container (docker-from-docker). | ||
|
@@ -197,8 +215,10 @@ You can connect to the running container like this: | |
``` | ||
#!/usr/bin/env bash | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
docker exec -it \ | ||
ubuntu-tini-x11 \ | ||
"${DOCKER_IMAGE_NAME}" \ | ||
bash -l | ||
``` | ||
|
||
|
@@ -255,8 +275,10 @@ You can stop the running container like this: | |
``` | ||
#!/usr/bin/env bash | ||
docker stop \ | ||
ubuntu-tini-x11 | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
docker stop \ | ||
"${DOCKER_IMAGE_NAME}" | ||
``` | ||
|
||
## Start | ||
|
@@ -266,8 +288,10 @@ If you run the container without --rm you can start it again like this: | |
``` | ||
#!/usr/bin/env bash | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
docker start \ | ||
ubuntu-tini-x11 | ||
"${DOCKER_IMAGE_NAME}" | ||
``` | ||
|
||
## Remove | ||
|
@@ -277,6 +301,8 @@ If you run the container without --rm you can remove once stopped like this: | |
``` | ||
#!/usr/bin/env bash | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
docker rm \ | ||
ubuntu-tini-x11 | ||
"${DOCKER_IMAGE_NAME}" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
DOCKER_REPOSITORY_NAME="rubensa" | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
DOCKER_IMAGE_TAG="latest" | ||
|
||
# NVidia propietary drivers are needed on host for this to work | ||
NVIDIA_VERSION=$(nvidia-smi --query-gpu=driver_version --format=csv,noheader) | ||
|
||
|
@@ -10,8 +14,14 @@ prepare_docker_nvidia_drivers_version() { | |
|
||
prepare_docker_nvidia_drivers_version | ||
|
||
docker build --no-cache \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
# see: https://github.com/docker/buildx/issues/495#issuecomment-761562905 | ||
#docker buildx build --platform=linux/amd64,linux/arm64 --no-cache --progress=plain --pull \ | ||
docker buildx build --platform=linux/amd64,linux/arm64 --no-cache \ | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
--label "maintainer=Ruben Suarez <[email protected]>" \ | ||
${BUILD_ARGS} \ | ||
. | ||
|
||
docker buildx build --load \ | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
DOCKER_REPOSITORY_NAME="rubensa" | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
DOCKER_IMAGE_TAG="latest" | ||
|
||
# see: https://github.com/docker/buildx/issues/495#issuecomment-761562905 | ||
#docker buildx build --platform=linux/amd64,linux/arm64 --no-cache --progress=plain --pull \ | ||
docker buildx build --platform=linux/amd64,linux/arm64 --no-cache \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
--label "maintainer=Ruben Suarez <[email protected]>" \ | ||
. | ||
|
||
docker buildx build --load \ | ||
-t "rubensa/ubuntu-tini-x11" \ | ||
. | ||
-t "${DOCKER_REPOSITORY_NAME}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
|
||
docker exec -it \ | ||
ubuntu-tini-x11 \ | ||
"${DOCKER_IMAGE_NAME}" \ | ||
bash -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
if ! (set -o noclobber ; echo > /tmp/install-nvidia-drivers.lock) ; then | ||
exit 1 # the install-nvidia-drivers.lock already exists | ||
exit 1 # the install-nvidia-drivers.lock already exists | ||
fi | ||
|
||
# Install NVIDIA drivers if NVIDIA_VERSION is set and not previously installed | ||
if [ ! -z ${NVIDIA_VERSION} ] && [ ! `command -v nvidia-smi` ]; then | ||
echo "# Downloading NVIDIA drivers matching host version (${NVIDIA_VERSION})..." | ||
curl -o nvidia.run -sSL http://us.download.nvidia.com/XFree86/Linux-x86_64/${NVIDIA_VERSION}/NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run | ||
chmod +x nvidia.run | ||
echo "# Installing NVIDIA drivers..." | ||
sudo ./nvidia.run --ui=none --no-kernel-module --no-install-compat32-libs --install-libglvnd --no-questions | ||
rm nvidia.run | ||
echo "# Downloading NVIDIA drivers matching host version (${NVIDIA_VERSION})..." | ||
curl -o nvidia.run -sSL http://us.download.nvidia.com/XFree86/Linux-x86_64/${NVIDIA_VERSION}/NVIDIA-Linux-x86_64-${NVIDIA_VERSION}.run | ||
chmod +x nvidia.run | ||
echo "# Installing NVIDIA drivers..." | ||
sudo ./nvidia.run --ui=none --no-kernel-module --no-install-compat32-libs --install-libglvnd --no-questions | ||
rm nvidia.run | ||
fi | ||
|
||
rm -f /tmp/install-nvidia-drivers.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
|
||
docker rm \ | ||
ubuntu-tini-x11 | ||
"${DOCKER_IMAGE_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker start -i \ | ||
ubuntu-tini-x11 | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
|
||
docker start \ | ||
"${DOCKER_IMAGE_NAME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
docker stop \ | ||
ubuntu-tini-x11 | ||
DOCKER_IMAGE_NAME="ubuntu-tini-x11" | ||
|
||
docker stop \ | ||
"${DOCKER_IMAGE_NAME}" |