-
Notifications
You must be signed in to change notification settings - Fork 6.3k
When container is recreated, automatically run a dependency setup script #7338
-
I am finally getting around to setting up a semi-production, private code-server
instance for myself on one of my home-lab Linux servers, with an NVIDIA GPU. One of the issues I foresee is that my dependencies will get "reset" every time a new version of the container is deployed. Every week or two, I run docker compose pull && docker compose up --detach
, to ensure I have the latest container images for my applications. If a new version of code-server
comes out, my installed tools like Rust, PowerShell, NVIDIA tools, etc. will be gone.
I understand that the general approach is to build a custom Dockerfile.
However ....
💡 Question: Rather than building my own Dockerfile
for code-server
, is there a way for me to launch a persisted script (mapped into container by Docker volume) upon launching a new code-server
container? I would rather run a script to install all my dependencies (eg. Rust Toolchain, PowerShell, NVIDIA utilities, etc.) than creating a Dockerfile. I generally prefer to use "stock" container images, rather than building my own, and then just inject whatever I need to at container runtime.
I am using Docker Compose to add code-server
to the list of other pre-packaged application containers I am running. I'm sharing the snippet below for docker-compose.yaml
, just in case anyone else is searching for it. I couldn't find it in the docs and created it myself.
vscode:
image: codercom/code-server:latest
ports:
- 10400:8080
volumes:
- ./code-server/.local:/home/coder/.local
- ./code-server/.config:/home/coder/.config
- ./code-server/project:/home/coder/project
environment:
- DOCKER_USER=${USER}
user: 1000:1000
restart: always
Beta Was this translation helpful? Give feedback.
All reactions
Actually you do not need to set ENTRYPOINTD
, it defaults to ${HOME}/entrypoint.d
, so you can mount your scripts there.
code-server/ci/release-image/Dockerfile
Line 52 in 47d6d3a
Replies: 1 comment 2 replies
-
The only method that comes to my mind is to change the entrypoint to a script of your own that installs the dependencies and then executes the original entrypoint.
And, we actually have an environment variable to make doing this easier: ENTRYPOINTD
(point it to a directory of scripts that you want to run before executing code-server).
code-server/ci/release-image/entrypoint.sh
Lines 21 to 25 in 47d6d3a
Beta Was this translation helpful? Give feedback.
All reactions
-
Actually you do not need to set ENTRYPOINTD
, it defaults to ${HOME}/entrypoint.d
, so you can mount your scripts there.
code-server/ci/release-image/Dockerfile
Line 52 in 47d6d3a
Beta Was this translation helpful? Give feedback.
All reactions
-
🚀 1
-
Very cool, thank you for that pointer. I will give this a try.
Beta Was this translation helpful? Give feedback.