Using Docker for Academic Research
- Note: Reading this post needs familiarity with Docker. If you are new to the Docker world, I suggest looking here. This post is more catered towards the steps required for creating and pushing images to DockerHub.*
Docker is a well-known tool. Although it is used prominently in the industry, there is a usage gap when talking about academic research. The main advantage of using Docker is that it allows the creation of images that ease the process of reproducibility. There have been various attempts to encourage reproducibility.
It is always a good idea to do experiments inside the Docker container so that the image of the container can be shared at the end. This would give the end users the same environment for conducting experiments and reduce a lot of environment setup time.
Use the following steps to create and publish a Docker image for your project:
Step.1.a: Check for the image of interest locally.
docker images
Step.1.b: If none, find an image of choice from DockerHub or any other source.
Step.2: Run the Docker image as a container.
docker run --gpus all -id --rm \
-v <cloned-repo>:/workspace \
--name <container-name> <docker-image>
Step.3: Get inside the container.
docker exec -it <container-name> /bin/bash # for bash shell
Step.4: Do the necessary changes, i.e., copy files, install packages, etc.
Step.5: Commit the changes.
docker commit \
--author <author-email> \
--message <commit-message> \
<container-name>
Step.6: Check for the IMAGE-ID.
docker ps # get IMAGE-ID
Step.7: Tag the IMAGE-ID with the local-name.
docker tag <IMAGE-ID> <local-name>
Step.8: Login using DockerHub username and password.
docker login -u <username>
# enter password on prompt
Step.9: Create a repository on DockerHub before proceeding, i.e. <username>/<repo>
.
Step.10: Tag IMAGE-ID with DockerHub <username>/<repo>
.
docker tag <IMAGE-ID> <username>/<repo>:<tag>
Step.11: Push the image to DockerHub.
docker push <username>/<repo>
Feel free to reach out in case you have a query. You are always welcome.
Please post it as a tweet to @jis_padalunkal, and I will definitely try to answer it.
@jis_padalunkal #askjishnu <your question>