How to write a Docker file
Last updated
Was this helpful?
Last updated
Was this helpful?
The usual way to get started building up a docker image is to use a base image. A base image is a pre-build Docker image that already has everything needed to run the container. We can then build our image on top of the base image.
You can check which images are . Building of a docker file should be conducted outside the sandbox. You can do this e.g. using google VM. After the docker file is done see instructions .
Our example for a Docker file is an .
Writing a Docker file starts with FROM command. With FROM a base image is selected. You can select a specific version using version number or select latest version using latest definition
Environmental variable is set with ENV command with a given name (e.g. ENV my_env_name 1.1). Environmental variables will be accessible by any processes running inside your image. For example setting environmental variable named R_VERSION and desired version number
WORKDIR command creates a directory of given name under current directory and use it as a working directory. All commands executed will use this working directory. For example, commands producing files will send produced files to this working directory. Docker file is read and executed line by line starting from the top. If folders need to go to another location as image building proceeds same WORKDIR command can be repeated. For example creating a working directory named tmp
Run command is used to execute packages inside the image. For example, to update and install dependences
With RUN command we can also install softwires from source and send them to environmental variables as e.g. in our example of
Example: See Samuel Jones user case of Docker image from .
For further information see
Tutorial video
Instructions and