-
Notifications
You must be signed in to change notification settings - Fork 7
Basics about Docker
Docker is a platform which help to build images which can be used to run commands in separated environments called containers. Each container is a sort of virtual environment that exist only to run a limited number of applications already installed in it, and images are the filesystem used by containers.
You can pull images from Docker Hub :
# Pull an image named wilga/openalea_python2 from Docker Hub
docker pull wilga/openalea_python2
You can also create a Dockerfile in you machine to build your own image :
# Create an image from a Dockerfile and name it openalea
docker build -t openalea /home/.../Dockerfile
Once the image is created by pulling or creating it, you can create a container :
# Run a container in interactive mode using the openalea image
docker run -it openalea
The -it option allow you to input commands in your container, else you need to include in your Dockerfile the commands you want to execute each run.
In OpenAlea, we use Docker to :
- Create a environment to run continuous integration tests with Travis
- Be able to launch easily some versions of OpenAlea as they were in the past.
This is most useful to run some old code or to get a stable version when the latest is not working with your project.
The Dockerfiles are the files that contains the code to create and run the environment in the container and install dependencies in it. They are some recurring commands like :
- FROM : First command in the file. Determine what the base image for the Docker is.
- WORKDIR : Set the directory where the program will run.
- RUN : Run a command.
- USER : Switch the user (default ROOT) to a new one. Keep in mind that some commands will not work without ROOT permission.
- ENV : Create an environment variable
You can also add others files in the directory containing the Dockerfile if needed.