I’ve built a docker image in order to publish a jupyter notebook to my team.
The jupyter notebook runs inside a docker container by running a docker run
command containing numerous arguments (such as mounts and environment variables for AWS credentials).
The current instructions I published for running the docker require you to copy and paste the entire docker run
command and execute it in a terminal window.
The script works fine, but I wonder if there is a way to specify the source from a file and run the docker run
command with that file as the run configuration (including the run arguments).
The idea is to do something similar to what applies when building an image with a Dockerfile
. Basically, you execute docker build -f ./Dockerfile
to build the image.
Is it possible to do something like this with docker run
?
I want to include my docker_run_configuration file (yml, json, etc.) at the project location and instruct the team to simply docker run -f ./docker_run_configuration.yml
.
2
Answers
The solution to your problem is docker compose.
Here are the official samples and guide.
Advanced TIP
You can pass external variables to YAML like in the following example:
You can use an
ENV MYVAR MYVALUE
in your Dockerfile.or you could set up
docker-compose.yaml
file,and run this command for example
docker compose --env-file .env up